=== modified file 'src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteUtils.cs'
--- src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteUtils.cs	2009-01-28 01:29:07 +0000
+++ src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteUtils.cs	2009-02-08 20:08:39 +0000
@@ -29,6 +29,7 @@
 using System;
 using System.Reflection;
 using System.Text;
+using Mono.Data.Sqlite;
 
 namespace Hyena.Data.Sqlite
 {
@@ -122,4 +123,17 @@
             return builder.ToString ();
         }
     }
+    
+    [SqliteFunction (Name = "HYENA_ESCAPE_LIKE", FuncType = FunctionType.Scalar, Arguments = 3)]
+    public class EscapeLikeFunction : SqliteFunction
+    {
+        public override object Invoke (object[] args)
+        {
+            string orig = args[1].ToString ();
+            string escaped = orig.Replace ("\\", "\\\\")
+                                 .Replace ("%", "\\%")
+                                 .Replace ("_", "\\_");
+            return String.Format ("{0}{1}{2}", args[0], escaped, args[2]);
+        }
+    }
 }

=== modified file 'src/Libraries/Hyena/Hyena.Query/StringQueryValue.cs'
--- src/Libraries/Hyena/Hyena.Query/StringQueryValue.cs	2008-07-20 23:05:30 +0000
+++ src/Libraries/Hyena/Hyena.Query/StringQueryValue.cs	2009-02-08 20:08:39 +0000
@@ -38,12 +38,14 @@
 {
     public class StringQueryValue : QueryValue
     {
-        public static readonly Operator Contains       = new Operator ("contains", Catalog.GetString ("contains"), "LIKE '%{0}%'", ":");
-        public static readonly Operator DoesNotContain = new Operator ("doesNotContain", Catalog.GetString ("doesn't contain"), "NOT LIKE '%{0}%'", true, "!:");
+        public static readonly Operator Contains       = new Operator ("contains", Catalog.GetString ("contains"), "LIKE HYENA_ESCAPE_LIKE('%','{0}','%')" + ESCAPE_CLAUSE, ":");
+        public static readonly Operator DoesNotContain = new Operator ("doesNotContain", Catalog.GetString ("doesn't contain"), "NOT LIKE HYENA_ESCAPE_LIKE('%','{0}','%')" + ESCAPE_CLAUSE, true, "!:");
         public static readonly Operator Equal          = new Operator ("equals", Catalog.GetString ("is"), "= '{0}'", "==");
         public static readonly Operator NotEqual       = new Operator ("notEqual", Catalog.GetString ("is not"), "!= '{0}'", true, "!=");
-        public static readonly Operator StartsWith     = new Operator ("startsWith", Catalog.GetString ("starts with"), "LIKE '{0}%'", "=");
-        public static readonly Operator EndsWith       = new Operator ("endsWith", Catalog.GetString ("ends with"), "LIKE '%{0}'", ":=");
+        public static readonly Operator StartsWith     = new Operator ("startsWith", Catalog.GetString ("starts with"), "LIKE HYENA_ESCAPE_LIKE('','{0}','%')" + ESCAPE_CLAUSE, "=");
+        public static readonly Operator EndsWith       = new Operator ("endsWith", Catalog.GetString ("ends with"), "LIKE HYENA_ESCAPE_LIKE('%','{0}','')" + ESCAPE_CLAUSE, ":=");
+
+        private const string ESCAPE_CLAUSE = " ESCAPE '\\'";
 
         protected string value;
 

