karishma-tirthani / odata4j

Automatically exported from code.google.com/p/odata4j
0 stars 0 forks source link

boolean filters broken for MS sqlserver #47

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. run an entity get with a filter like: $filter=substringof('emission', 
AlertMessage) eq true

What is the expected output? What do you see instead?
no entity returned

Please use labels and text to provide additional information.

query generated has a clause:  (CASE WHEN MyTable.AlertMessage LIKE 
'%emission%' THEN TRUE ELSE FALSE END) = true

this is not valid transact SQL.  A more portable solution may be:

(CASE WHEN MyTable.AlertMessage LIKE '%emission%' THEN 1 ELSE 0 END) = 1

Original issue reported on code.google.com by tony.ro...@gmail.com on 16 Jun 2011 at 5:43

GoogleCodeExporter commented 8 years ago
When executing an OData request like yours I am getting correct entities 
returned by SQL Server 2008 R2 using odata4j 0.4 and EclipseLink 2.1.2.  

The EcliseLink logs show that it is using JDBC PreparedStatements.  So the logs 
show something like this:

CASE WHEN MyTable.AlertMessage LIKE ? THEN ? ELSE ? END = ?
   bind => [%emission%, true, false, true]

With the use of a PreparedStatement the JDBC driver should convert that to the 
proper T-SQL.  I imagine that is why it works for me.  

Are you really seeing the log you showed from EclipseLink?  Your log looks like 
a PreparedStatement is not being used by EclipseLink.  Have you disabled 
EclipseLinks use of PreparedStatement?

Or are you using Hibernate or OpenJPA rather than EclipseLink?

Original comment by slvjer...@gmail.com on 1 Nov 2011 at 6:04

GoogleCodeExporter commented 8 years ago
Sorry, forgot to mention that my JDBC driver is jtds 1.2.4.

Original comment by slvjer...@gmail.com on 1 Nov 2011 at 6:10

GoogleCodeExporter commented 8 years ago
I'm not sure what I was thinking on this one, clearly not a defect, sorry.

Original comment by tony.ro...@gmail.com on 9 Nov 2011 at 3:46