datamapper / do

DataObjects
147 stars 74 forks source link

escape_sql fails on escaped quotes #38

Closed hannesg closed 12 years ago

hannesg commented 12 years ago

Hi

escape_sql currently fails when the SQL contains escaped quotes. I fixed this and added a spec for it.

Have fun Hannes Georg

travisbot commented 12 years ago

This pull request passes (merged d6ac70ac into 329b716a).

dbussink commented 12 years ago

Backslashes are actually not the character one should use for escaping. The SQL standard defines ' as the escape character. This change would break queries that correctly use this character to escape instead of the unofficial but sometimes working \ character (depending on which mode you connect).

On MySQL we actually set the NO_BACKSLASH_ESCAPES option so that backslashes work just like they should according to the SQL specification. On PostgreSQL we do "SET backslash_quote = off" to also disable backslashes as quotes.

hannesg commented 12 years ago

Okay, I wasn't aware of that.