datajoint/datajoint-matlab — pull request #14 by ahoenselaar (2013-08-21 22:08:13+00:00)
Title: Escaping of string literals in struct2cond

String literals in `struct2cond` are not escaped correctly. Queries like

acq.EventstringsUnique(struct('eventstring', 'foo "bar"'))
will cause an SQL error because string literals are enclosed in double quotation marks and the user-supplied string is not escaped in any way.
The attached patch changes this behavior twofold:

1. String literals are now enclosed in single quotation marks. This is closer to the SQL standard and makes the code independent from the MySQL server mode
2. Single quotation marks are correctly escaped using two single quotation mark characters

With this patch, both

acq.EventstringsUnique(struct('eventstring', 'foo "bar"'))
and

acq.EventstringsUnique(struct('eventstring', 'foo ''bar'''))
create valid SQL statements and the expected query results.