You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by "Thoralf Rickert (JIRA)" <ji...@apache.org> on 2006/10/09 12:04:19 UTC

[jira] Created: (TORQUE-59) correctBooleans() overwrites complex boolean criteria

correctBooleans() overwrites complex boolean criteria
-----------------------------------------------------

                 Key: TORQUE-59
                 URL: http://issues.apache.org/jira/browse/TORQUE-59
             Project: Torque
          Issue Type: Bug
          Components: Runtime
    Affects Versions: 3.2
         Environment: MySQL 5
            Reporter: Thoralf Rickert


If you have a table with a nullable boolean column:

  <column name="test" type="booleanint" size="1"/>

and create a criteria like this:

    Criterion c1 = criteria.getNewCriterion(TEST, false, Criteria.EQUAL);
    Criterion c2 = criteria.getNewCriterion(TEST, null, Criteria.ISNULL);
    criteria.add(c1.or(c2));

then the createQueryString returns the correct toString() result with

   ...WHERE (TEST = 0 or TEST IS NULL) ...

but when you call doSelect(), it sends just TEST = 0 to the database.

The problem is in the generated correctBooleans(Criteria) method. It checks if the Criteria contains one of the boolean column and replaces the criterion with an int value. So, in the above situation it removes the Criteria.ISNULL part...that is not expected.

       .....
       if (criteria.containsKey(TEST))
        {
            Object possibleBoolean = criteria.get(TEST);
            if (possibleBoolean instanceof Boolean)
            {
                criteria.add(TEST, ((Boolean) possibleBoolean).booleanValue() ? 1 : 0);
            }
         }

The only possible workaround is to use the integer value (0,1) in the criterion (Criterion c1 = criteria.getNewCriterion(TEST, 0, Criteria.EQUAL) ). But this is not expected, because it is database specific.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


[jira] Resolved: (TORQUE-59) correctBooleans() overwrites complex boolean criteria

Posted by "Thomas Fischer (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/TORQUE-59?page=all ]

Thomas Fischer resolved TORQUE-59.
----------------------------------

    Fix Version/s: 3.2.1
       Resolution: Fixed
         Assignee: Thomas Fischer

> correctBooleans() overwrites complex boolean criteria
> -----------------------------------------------------
>
>                 Key: TORQUE-59
>                 URL: http://issues.apache.org/jira/browse/TORQUE-59
>             Project: Torque
>          Issue Type: Bug
>          Components: Runtime
>    Affects Versions: 3.2
>         Environment: MySQL 5
>            Reporter: Thoralf Rickert
>         Assigned To: Thomas Fischer
>             Fix For: 3.2.1
>
>
> If you have a table with a nullable boolean column:
>   <column name="test" type="booleanint" size="1"/>
> and create a criteria like this:
>     Criterion c1 = criteria.getNewCriterion(TEST, false, Criteria.EQUAL);
>     Criterion c2 = criteria.getNewCriterion(TEST, null, Criteria.ISNULL);
>     criteria.add(c1.or(c2));
> then the createQueryString returns the correct toString() result with
>    ...WHERE (TEST = 0 or TEST IS NULL) ...
> but when you call doSelect(), it sends just TEST = 0 to the database.
> The problem is in the generated correctBooleans(Criteria) method. It checks if the Criteria contains one of the boolean column and replaces the criterion with an int value. So, in the above situation it removes the Criteria.ISNULL part...that is not expected.
>        .....
>        if (criteria.containsKey(TEST))
>         {
>             Object possibleBoolean = criteria.get(TEST);
>             if (possibleBoolean instanceof Boolean)
>             {
>                 criteria.add(TEST, ((Boolean) possibleBoolean).booleanValue() ? 1 : 0);
>             }
>          }
> The only possible workaround is to use the integer value (0,1) in the criterion (Criterion c1 = criteria.getNewCriterion(TEST, 0, Criteria.EQUAL) ). But this is not expected, because it is database specific.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


[jira] Closed: (TORQUE-59) correctBooleans() overwrites complex boolean criteria

Posted by "Thomas Vandahl (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/TORQUE-59?page=all ]

Thomas Vandahl closed TORQUE-59.
--------------------------------


> correctBooleans() overwrites complex boolean criteria
> -----------------------------------------------------
>
>                 Key: TORQUE-59
>                 URL: http://issues.apache.org/jira/browse/TORQUE-59
>             Project: Torque
>          Issue Type: Bug
>          Components: Runtime
>    Affects Versions: 3.2
>         Environment: MySQL 5
>            Reporter: Thoralf Rickert
>         Assigned To: Thomas Fischer
>             Fix For: 3.3
>
>
> If you have a table with a nullable boolean column:
>   <column name="test" type="booleanint" size="1"/>
> and create a criteria like this:
>     Criterion c1 = criteria.getNewCriterion(TEST, false, Criteria.EQUAL);
>     Criterion c2 = criteria.getNewCriterion(TEST, null, Criteria.ISNULL);
>     criteria.add(c1.or(c2));
> then the createQueryString returns the correct toString() result with
>    ...WHERE (TEST = 0 or TEST IS NULL) ...
> but when you call doSelect(), it sends just TEST = 0 to the database.
> The problem is in the generated correctBooleans(Criteria) method. It checks if the Criteria contains one of the boolean column and replaces the criterion with an int value. So, in the above situation it removes the Criteria.ISNULL part...that is not expected.
>        .....
>        if (criteria.containsKey(TEST))
>         {
>             Object possibleBoolean = criteria.get(TEST);
>             if (possibleBoolean instanceof Boolean)
>             {
>                 criteria.add(TEST, ((Boolean) possibleBoolean).booleanValue() ? 1 : 0);
>             }
>          }
> The only possible workaround is to use the integer value (0,1) in the criterion (Criterion c1 = criteria.getNewCriterion(TEST, 0, Criteria.EQUAL) ). But this is not expected, because it is database specific.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org