Vaibhav95g / h2database

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

Backslash must be escaped for like but not for equals #413

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

What steps will reproduce the problem?
Create a table with a row that contains a single column with just a backslash 
as value. Then try to select it using equals or like. The behaviour for like 
and equals is different. One requires the backslash to be escaped, the other 
one does not. This behaviour can be reproduced using the H2 Console:

Works, selects my row:
SELECT * FROM mytable where mycolumn = '\'
SELECT * FROM mytable where mycolumn like  '\\'
SELECT * FROM mytable where mycolumn like  '%\\%'

Does not work, wont select my row:
SELECT * FROM mytable where mycolumn = '\\'
SELECT * FROM mytable where mycolumn like  '\'
SELECT * FROM mytable where mycolumn like  '%\%'

What is the expected output? What do you see instead?
I would expect that I either have to escape the backslash or not. But it should 
be same behaviour for like and equals.

What version of the product are you using? On what operating system, file
system, and virtual machine?
I'm using H2 1.3.161 on Linux. Java 1.7.0_03

How important/urgent is the problem for you?
Low

Original issue reported on code.google.com by hors...@gmail.com on 7 Aug 2012 at 9:34

GoogleCodeExporter commented 9 years ago
This is the documented and correct (according to the SQL specification) 
behavior. It is not a bug.

Original comment by thomas.t...@gmail.com on 7 Aug 2012 at 8:31

GoogleCodeExporter commented 9 years ago
Thanks Thomas.

I did not find something mentioning the difference between the two explicitly. 
But yes its there :)

Nevertheless this makes sense. Only likes need to escape anything (% _ ? and \ 
itself). There is no such need for equals of course.

cheers,
Christian

Original comment by hors...@gmail.com on 7 Aug 2012 at 8:55