EntityOperator.IN will crash on some databases with empty list
-------------------------------------------------------------- Key: OFBIZ-1266 URL: https://issues.apache.org/jira/browse/OFBIZ-1266 Project: OFBiz Issue Type: Bug Components: framework Affects Versions: SVN trunk Environment: derby, unkown other databases Reporter: Leon Torres If you use the following entity exr, new EntityExpr("orderId", EntityOperator.IN, new ArrayList()); It will crash on at least Derby. The reason is that this condition evaluates to the keyword FALSE, which apparently is not supported on Derby. The problem code is in EntityComparisonOperator.java: // if this is an IN operator and the rhs Object isEmpty, add "FALSE" instead of the normal SQL if (this.idInt == EntityOperator.ID_IN && UtilValidate.isEmpty(rhs)) { sql.append("FALSE"); return; } Perhaps this is over engineered? What happens if we just leave this out and let it generate an "IN ()" SQL? -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
[ https://issues.apache.org/jira/browse/OFBIZ-1266?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12531298 ] Jacques Le Roux commented on OFBIZ-1266: ---------------------------------------- Hi Leon, Did you try ? Have you an use case ? > EntityOperator.IN will crash on some databases with empty list > -------------------------------------------------------------- > > Key: OFBIZ-1266 > URL: https://issues.apache.org/jira/browse/OFBIZ-1266 > Project: OFBiz > Issue Type: Bug > Components: framework > Affects Versions: SVN trunk > Environment: derby, unkown other databases > Reporter: Leon Torres > > If you use the following entity exr, > new EntityExpr("orderId", EntityOperator.IN, new ArrayList()); > It will crash on at least Derby. The reason is that this condition evaluates to the keyword FALSE, which apparently is not supported on Derby. The problem code is in EntityComparisonOperator.java: > // if this is an IN operator and the rhs Object isEmpty, add "FALSE" instead of the normal SQL > if (this.idInt == EntityOperator.ID_IN && UtilValidate.isEmpty(rhs)) { > sql.append("FALSE"); > return; > } > Perhaps this is over engineered? What happens if we just leave this out and let it generate an "IN ()" SQL? -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
In reply to this post by Nicolas Malin (Jira)
[ https://issues.apache.org/jira/browse/OFBIZ-1266?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12534650 ] Adam Heath commented on OFBIZ-1266: ----------------------------------- Derby doesn't support FALSE in conditions? Seems like a derby bug. However, if derby won't be supporting that any time soon, we may have to come up with a workaround. :( > EntityOperator.IN will crash on some databases with empty list > -------------------------------------------------------------- > > Key: OFBIZ-1266 > URL: https://issues.apache.org/jira/browse/OFBIZ-1266 > Project: OFBiz > Issue Type: Bug > Components: framework > Affects Versions: SVN trunk > Environment: derby, unkown other databases > Reporter: Leon Torres > > If you use the following entity exr, > new EntityExpr("orderId", EntityOperator.IN, new ArrayList()); > It will crash on at least Derby. The reason is that this condition evaluates to the keyword FALSE, which apparently is not supported on Derby. The problem code is in EntityComparisonOperator.java: > // if this is an IN operator and the rhs Object isEmpty, add "FALSE" instead of the normal SQL > if (this.idInt == EntityOperator.ID_IN && UtilValidate.isEmpty(rhs)) { > sql.append("FALSE"); > return; > } > Perhaps this is over engineered? What happens if we just leave this out and let it generate an "IN ()" SQL? -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
In reply to this post by Nicolas Malin (Jira)
[ https://issues.apache.org/jira/browse/OFBIZ-1266?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Adam Heath reassigned OFBIZ-1266: --------------------------------- Assignee: Adam Heath > EntityOperator.IN will crash on some databases with empty list > -------------------------------------------------------------- > > Key: OFBIZ-1266 > URL: https://issues.apache.org/jira/browse/OFBIZ-1266 > Project: OFBiz > Issue Type: Bug > Components: framework > Affects Versions: SVN trunk > Environment: derby, unkown other databases > Reporter: Leon Torres > Assignee: Adam Heath > > If you use the following entity exr, > new EntityExpr("orderId", EntityOperator.IN, new ArrayList()); > It will crash on at least Derby. The reason is that this condition evaluates to the keyword FALSE, which apparently is not supported on Derby. The problem code is in EntityComparisonOperator.java: > // if this is an IN operator and the rhs Object isEmpty, add "FALSE" instead of the normal SQL > if (this.idInt == EntityOperator.ID_IN && UtilValidate.isEmpty(rhs)) { > sql.append("FALSE"); > return; > } > Perhaps this is over engineered? What happens if we just leave this out and let it generate an "IN ()" SQL? -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
In reply to this post by Nicolas Malin (Jira)
[ https://issues.apache.org/jira/browse/OFBIZ-1266?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12534739 ] Jacopo Cappellato commented on OFBIZ-1266: ------------------------------------------ It would be great to post a message to the Apache Derby dev mailing list asking about this: in the past they have been very kind and responsive. > EntityOperator.IN will crash on some databases with empty list > -------------------------------------------------------------- > > Key: OFBIZ-1266 > URL: https://issues.apache.org/jira/browse/OFBIZ-1266 > Project: OFBiz > Issue Type: Bug > Components: framework > Affects Versions: SVN trunk > Environment: derby, unkown other databases > Reporter: Leon Torres > Assignee: Adam Heath > > If you use the following entity exr, > new EntityExpr("orderId", EntityOperator.IN, new ArrayList()); > It will crash on at least Derby. The reason is that this condition evaluates to the keyword FALSE, which apparently is not supported on Derby. The problem code is in EntityComparisonOperator.java: > // if this is an IN operator and the rhs Object isEmpty, add "FALSE" instead of the normal SQL > if (this.idInt == EntityOperator.ID_IN && UtilValidate.isEmpty(rhs)) { > sql.append("FALSE"); > return; > } > Perhaps this is over engineered? What happens if we just leave this out and let it generate an "IN ()" SQL? -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
In reply to this post by Nicolas Malin (Jira)
Uma lista de condiçoes vazias é desaconselhada.
2007/10/14, Adam Heath (JIRA) <[hidden email]>: > > > [ > https://issues.apache.org/jira/browse/OFBIZ-1266?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12534650] > > Adam Heath commented on OFBIZ-1266: > ----------------------------------- > > Derby doesn't support FALSE in conditions? Seems like a derby > bug. However, if derby won't be supporting that any time soon, we may have > to come up with a workaround. :( > > > EntityOperator.IN will crash on some databases with empty list > > -------------------------------------------------------------- > > > > Key: OFBIZ-1266 > > URL: https://issues.apache.org/jira/browse/OFBIZ-1266 > > Project: OFBiz > > Issue Type: Bug > > Components: framework > > Affects Versions: SVN trunk > > Environment: derby, unkown other databases > > Reporter: Leon Torres > > > > If you use the following entity exr, > > new EntityExpr("orderId", EntityOperator.IN, new ArrayList()); > > It will crash on at least Derby. The reason is that this condition > evaluates to the keyword FALSE, which apparently is not supported on > Derby. The problem code is in EntityComparisonOperator.java: > > // if this is an IN operator and the rhs Object isEmpty, add > "FALSE" instead of the normal SQL > > if (this.idInt == EntityOperator.ID_IN && UtilValidate.isEmpty(rhs)) > { > > sql.append("FALSE"); > > return; > > } > > Perhaps this is over engineered? What happens if we just leave this out > and let it generate an "IN ()" SQL? > > -- > This message is automatically generated by JIRA. > - > You can reply to this email to add a comment to the issue online. > > |
Administrator
|
Is it related to the endemic NULL concept in Postgres ?
Jacques De : "Rodrigo Souza" <[hidden email]> Uma lista de condiçoes vazias é desaconselhada. 2007/10/14, Adam Heath (JIRA) <[hidden email]>: > > > [ > https://issues.apache.org/jira/browse/OFBIZ-1266?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12534650] > > Adam Heath commented on OFBIZ-1266: > ----------------------------------- > > Derby doesn't support FALSE in conditions? Seems like a derby > bug. However, if derby won't be supporting that any time soon, we may have > to come up with a workaround. :( > > > EntityOperator.IN will crash on some databases with empty list > > -------------------------------------------------------------- > > > > Key: OFBIZ-1266 > > URL: https://issues.apache.org/jira/browse/OFBIZ-1266 > > Project: OFBiz > > Issue Type: Bug > > Components: framework > > Affects Versions: SVN trunk > > Environment: derby, unkown other databases > > Reporter: Leon Torres > > > > If you use the following entity exr, > > new EntityExpr("orderId", EntityOperator.IN, new ArrayList()); > > It will crash on at least Derby. The reason is that this condition > evaluates to the keyword FALSE, which apparently is not supported on > Derby. The problem code is in EntityComparisonOperator.java: > > // if this is an IN operator and the rhs Object isEmpty, add > "FALSE" instead of the normal SQL > > if (this.idInt == EntityOperator.ID_IN && UtilValidate.isEmpty(rhs)) > { > > sql.append("FALSE"); > > return; > > } > > Perhaps this is over engineered? What happens if we just leave this out > and let it generate an "IN ()" SQL? > > -- > This message is automatically generated by JIRA. > - > You can reply to this email to add a comment to the issue online. > > |
In reply to this post by Nicolas Malin (Jira)
[ https://issues.apache.org/jira/browse/OFBIZ-1266?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12680218#action_12680218 ] Wickersheimer Jeremy commented on OFBIZ-1266: --------------------------------------------- This bug also affects Oracle databases, the problem is the same as in Derby, boolean types are not supported. Why not just change the 'FALSE' to '0=1' and then work with all the databases that do not support booleans ? > EntityOperator.IN will crash on some databases with empty list > -------------------------------------------------------------- > > Key: OFBIZ-1266 > URL: https://issues.apache.org/jira/browse/OFBIZ-1266 > Project: OFBiz > Issue Type: Bug > Components: framework > Affects Versions: SVN trunk > Environment: derby, unkown other databases > Reporter: Leon Torres > Assignee: Adam Heath > > If you use the following entity exr, > new EntityExpr("orderId", EntityOperator.IN, new ArrayList()); > It will crash on at least Derby. The reason is that this condition evaluates to the keyword FALSE, which apparently is not supported on Derby. The problem code is in EntityComparisonOperator.java: > // if this is an IN operator and the rhs Object isEmpty, add "FALSE" instead of the normal SQL > if (this.idInt == EntityOperator.ID_IN && UtilValidate.isEmpty(rhs)) { > sql.append("FALSE"); > return; > } > Perhaps this is over engineered? What happens if we just leave this out and let it generate an "IN ()" SQL? -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
In reply to this post by Nicolas Malin (Jira)
[ https://issues.apache.org/jira/browse/OFBIZ-1266?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Wickersheimer Jeremy updated OFBIZ-1266: ---------------------------------------- Attachment: 1266.patch Patch that replaces WHERE FALSE condition to WHERE 1=0 > EntityOperator.IN will crash on some databases with empty list > -------------------------------------------------------------- > > Key: OFBIZ-1266 > URL: https://issues.apache.org/jira/browse/OFBIZ-1266 > Project: OFBiz > Issue Type: Bug > Components: framework > Affects Versions: SVN trunk > Environment: derby, unkown other databases > Reporter: Leon Torres > Assignee: Adam Heath > Attachments: 1266.patch > > > If you use the following entity exr, > new EntityExpr("orderId", EntityOperator.IN, new ArrayList()); > It will crash on at least Derby. The reason is that this condition evaluates to the keyword FALSE, which apparently is not supported on Derby. The problem code is in EntityComparisonOperator.java: > // if this is an IN operator and the rhs Object isEmpty, add "FALSE" instead of the normal SQL > if (this.idInt == EntityOperator.ID_IN && UtilValidate.isEmpty(rhs)) { > sql.append("FALSE"); > return; > } > Perhaps this is over engineered? What happens if we just leave this out and let it generate an "IN ()" SQL? -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
In reply to this post by Nicolas Malin (Jira)
[ https://issues.apache.org/jira/browse/OFBIZ-1266?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12681845#action_12681845 ] Si Chen commented on OFBIZ-1266: -------------------------------- would anybody be opposed if I committed Jeremy's patch? > EntityOperator.IN will crash on some databases with empty list > -------------------------------------------------------------- > > Key: OFBIZ-1266 > URL: https://issues.apache.org/jira/browse/OFBIZ-1266 > Project: OFBiz > Issue Type: Bug > Components: framework > Affects Versions: SVN trunk > Environment: derby, unkown other databases > Reporter: Leon Torres > Assignee: Adam Heath > Attachments: 1266.patch > > > If you use the following entity exr, > new EntityExpr("orderId", EntityOperator.IN, new ArrayList()); > It will crash on at least Derby. The reason is that this condition evaluates to the keyword FALSE, which apparently is not supported on Derby. The problem code is in EntityComparisonOperator.java: > // if this is an IN operator and the rhs Object isEmpty, add "FALSE" instead of the normal SQL > if (this.idInt == EntityOperator.ID_IN && UtilValidate.isEmpty(rhs)) { > sql.append("FALSE"); > return; > } > Perhaps this is over engineered? What happens if we just leave this out and let it generate an "IN ()" SQL? -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
In reply to this post by Nicolas Malin (Jira)
[ https://issues.apache.org/jira/browse/OFBIZ-1266?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12682004#action_12682004 ] Jacopo Cappellato commented on OFBIZ-1266: ------------------------------------------ Hi Si, I think it is an acceptable workaround, but if we commit the patch we have to add more comments that explain the solution adopted and why. Another option would be that of throwing an exception if an empty list is passed to the IN operand: the calling code could be responsible of deciding how to treat this situation (if empty means no record then the call is useless, if it means all the records then the IN constraint can be skipped). > EntityOperator.IN will crash on some databases with empty list > -------------------------------------------------------------- > > Key: OFBIZ-1266 > URL: https://issues.apache.org/jira/browse/OFBIZ-1266 > Project: OFBiz > Issue Type: Bug > Components: framework > Affects Versions: SVN trunk > Environment: derby, unkown other databases > Reporter: Leon Torres > Assignee: Adam Heath > Attachments: 1266.patch > > > If you use the following entity exr, > new EntityExpr("orderId", EntityOperator.IN, new ArrayList()); > It will crash on at least Derby. The reason is that this condition evaluates to the keyword FALSE, which apparently is not supported on Derby. The problem code is in EntityComparisonOperator.java: > // if this is an IN operator and the rhs Object isEmpty, add "FALSE" instead of the normal SQL > if (this.idInt == EntityOperator.ID_IN && UtilValidate.isEmpty(rhs)) { > sql.append("FALSE"); > return; > } > Perhaps this is over engineered? What happens if we just leave this out and let it generate an "IN ()" SQL? -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
In reply to this post by Nicolas Malin (Jira)
[ https://issues.apache.org/jira/browse/OFBIZ-1266?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Si Chen closed OFBIZ-1266. -------------------------- Resolution: Fixed > EntityOperator.IN will crash on some databases with empty list > -------------------------------------------------------------- > > Key: OFBIZ-1266 > URL: https://issues.apache.org/jira/browse/OFBIZ-1266 > Project: OFBiz > Issue Type: Bug > Components: framework > Affects Versions: SVN trunk > Environment: derby, unkown other databases > Reporter: Leon Torres > Assignee: Adam Heath > Attachments: 1266.patch > > > If you use the following entity exr, > new EntityExpr("orderId", EntityOperator.IN, new ArrayList()); > It will crash on at least Derby. The reason is that this condition evaluates to the keyword FALSE, which apparently is not supported on Derby. The problem code is in EntityComparisonOperator.java: > // if this is an IN operator and the rhs Object isEmpty, add "FALSE" instead of the normal SQL > if (this.idInt == EntityOperator.ID_IN && UtilValidate.isEmpty(rhs)) { > sql.append("FALSE"); > return; > } > Perhaps this is over engineered? What happens if we just leave this out and let it generate an "IN ()" SQL? -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
Free forum by Nabble | Edit this page |