Google+ Followers

zondag 27 april 2014

Stupid quotes

SELECT 'foo' IN ('foo'
                 'bar');
 ?column? 
----------
 f
(1 row)


So what went wrong here?  Two things. The linebreak in the query is just presentation and when it's left out you get:

SELECT 'foo' IN ('foo''bar');
 ?column? 
----------
 f
(1 row)

Which makes sense because the two singlequots form an escaped singlequote. The comparison is actually against "foo'bar", and of course that's not equal to "foo".