Cam Tucker - 101 - May 12, 2014

4.0.19 & 4.0.20 OrmLite .Contains() is producing incorrect SQL for MySql, or I’ve done something wrong. I think it was working in 4.0.18. Is there a test that makes sure MySql is okay with the escape(’\’) ?

That commit highlights the Can_escape_wildcards() test you can use.
That test works against my local MySql instance.

Cam Tucker:

That test only covers .StartsWith() - which is working fine for me.

.Contains() seems to produce an escape(’’) when it should be escape(’\’) to work with MySql.

Cam Tucker:

My sqlexpression is:

var ev = db.From<Person>();
var phoneScrubbed = “some phone number”;
ev.Where(p => p.phone_home.Contains(phoneScrubbed) || p.phone_cell.Contains(phoneScrubbed) || p.phone_bus.Contains(phoneScrubbed));
ev.OrderBy(p => p.last_name).ThenBy(p => p.first_name);
return db.Select(ev);

ok I’ve had to swap the escape character because it behaves differently in MySql, in this commit:

Which is now on MyGet: