[Nitro] Quoting/protecting fields

David Legard dalegard at gmail.com
Thu Sep 29 20:08:05 EDT 2005


I am moving some legacy data onto Og/MySQL.
 The problem is that many of the names have been entered with single- or
double- quotes.
 ie Massey-Ferguson "Giant" Tractor
or 2003 Moondarra Holly's Pinot Gris
 If I write:
db.select(%Q/WHERE name=#"{nm}"/) it fails with an SQL syntax error on a
double quote, as does
db["#{nm}"]
 and of course if I put single quotes in the code, it then fails on the
single quotes.
 The question is: is there an easy function to protect these names, akin to
SQLite's:
 name=SQLite::Database.quote(nm)
 David L.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/nitro-general/attachments/20050929/9ce4a6bf/attachment.html 


More information about the Nitro-general mailing list