Uploaded image for project: 'Apache MetaModel (Retired)'
  1. Apache MetaModel (Retired)
  2. METAMODEL-232

Incorrect Select Count Using Where Clause with Type Conversion

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 4.5.0
    • None
    • None

    Description

      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:

      Query selectAllQuery = dataContext.query()
      		.from(TABLE)
      		.selectAll()
      		.where(FunctionType.TO_NUMBER, COLUMN).lessThan(lessThanNumber)
      		.toQuery();
      

      ... may not equal the count from the following:

      Query selectCountQuery = dataContext.query()
      		.from(TABLE)
      		.selectCount()
      		.where(FunctionType.TO_NUMBER, COLUMN).lessThan(lessThanNumber)
      		.toQuery();
      

      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.

      Attachments

        1. data-source-test-3.xlsx
          9 kB
          Michael Diep
        2. CountTest.java
          2 kB
          Michael Diep

        Activity

          People

            Unassigned Unassigned
            MADiep Michael Diep
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: