Daniel Hagen wrote:
I am struggeling with a SQL Query containing ' characters.
As I understand the spec (section 8.5.4.5), the query
SELECT <field-list> FROM <nodetype> WHERE CONTAINS(*, 'O\'Hara') ORDER BY
<field-list>

should return all nodes having properties containing the word O'Hara .

section 8.5.4.5 only talks about escaping of the search expression itself, but not about escaping a string literal in general when used in SQL. the backslash is used to compensate the otherwise semantic meaning of the characters: " (double quote), - (hyphen) and ' (single quote) though IMO the single quote does not actually need escaping because the contains function does not define a semantic for a single quote in the search expression.

so, your contains literal is basically correct, but it does not respect the SQL syntax. a single quote in a string literal needs to be escaped with an additional single quote. the correct expression is:

CONTAINS(*, 'O\''Hara')

as I mentioned already, because there is no semantic meaning to a single quote jackrabbit also accepts and treats the following expression equivalent:

CONTAINS(*, 'O''Hara')

regards
 marcel

Reply via email to