Fix filter row SQL generation to always produce correct SQL statements

Always produce correct SQL statements, even when using an incomplete
comparison operator.

Fix escaping to make it possible to search for '-charachters.