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(’\’) ?

https://github.com/ServiceStack/ServiceStack.OrmLite/commit/5016868b5f7f1c12ef580223926fd386e2f54e06

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: https://github.com/ServiceStack/ServiceStack.OrmLite/commit/8e7ed941f1269054a62a1e6c2af5d83afca25b0e

Which is now on MyGet:
https://github.com/ServiceStack/ServiceStack/wiki/MyGet