You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@metamodel.apache.org by "Michael Diep (JIRA)" <ji...@apache.org> on 2016/02/05 21:29:39 UTC

[jira] [Created] (METAMODEL-232) Incorrect Select Count Using Where Clause with Type Conversion

Michael Diep created METAMODEL-232:
--------------------------------------

             Summary: Incorrect Select Count Using Where Clause with Type Conversion
                 Key: METAMODEL-232
                 URL: https://issues.apache.org/jira/browse/METAMODEL-232
             Project: Apache MetaModel
          Issue Type: Bug
    Affects Versions: 4.5.0
            Reporter: Michael Diep
            Priority: Minor


I've found an issue where using select count in a query where columns have been converted from a String does not return the correct result. However, when running the same query with a select *, the correct number of Rows will be in the DataSet.

In other words, the number of Rows from the following:
{code}
Query selectAllQuery = dataContext.query()
		.from(TABLE)
		.selectAll()
		.where(FunctionType.TO_NUMBER, COLUMN).lessThan(lessThanNumber)
		.toQuery();
{code}

... may not equal the count from the following:
{code}
Query selectCountQuery = dataContext.query()
		.from(TABLE)
		.selectCount()
		.where(FunctionType.TO_NUMBER, COLUMN).lessThan(lessThanNumber)
		.toQuery();
{code}

The issue seems to be due to the select count query making comparisons based on the actual column type (a String) against a given operand (a non-String).

I've only tested this with Excel, but I imagine it could happen with any DataContext where all of the data types are read as Strings (e.g. CSV).

I will attach a test with a sample file that showcases the issue.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)