=== modified file 'src/Libraries/Hyena/Hyena.Query/ExactStringQueryValue.cs'
--- src/Libraries/Hyena/Hyena.Query/ExactStringQueryValue.cs	2009-02-11 05:30:06 +0000
+++ src/Libraries/Hyena/Hyena.Query/ExactStringQueryValue.cs	2009-02-20 20:00:00 +0000
@@ -33,7 +33,7 @@
     {
         public override string ToSql (Operator op)
         {
-            return String.IsNullOrEmpty (value) ? null : value.Replace ("'", "''").ToLower ();
+            return String.IsNullOrEmpty (value) ? null : EscapeString (op, value.ToLower ());
         }
     }
 }

=== modified file 'src/Libraries/Hyena/Hyena.Query/StringQueryValue.cs'
--- src/Libraries/Hyena/Hyena.Query/StringQueryValue.cs	2009-02-11 05:30:06 +0000
+++ src/Libraries/Hyena/Hyena.Query/StringQueryValue.cs	2009-02-20 20:00:04 +0000
@@ -81,28 +81,20 @@
 
         public override string ToSql (Operator op)
         {
-            if (String.IsNullOrEmpty (value))
-                return null;
-
-            string ret = null;
-
-            // SearchKey() removes ' anyway, but it's escaped again so proper
-            // SQL behavior isn't dependent on search behavior.
-            ret = Hyena.StringUtil.SearchKey (value).Replace ("'", "''");
-
+            return String.IsNullOrEmpty (value) ? null : EscapeString (op, Hyena.StringUtil.SearchKey (value));
+        }
+
+        public static string EscapeString (Operator op, string orig)
+        {
+            orig = orig.Replace ("'", "''");
             if (op == Contains   || op == DoesNotContain ||
                 op == StartsWith || op == EndsWith) {
-                ret = EscapeLike (ret);
+                return orig.Replace ("\\", "\\\\")
+                           .Replace ("%", "\\%")
+                           .Replace ("_", "\\_");
             }
-
-            return ret;
-        }
-
-        private static string EscapeLike (string orig)
-        {
-            return orig.Replace ("\\", "\\\\")
-                       .Replace ("%", "\\%")
-                       .Replace ("_", "\\_");
+            
+            return orig;
         }
     }
 }

