-
-
Save practicingruby/2829478 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def update(id, params) | |
| # FIXME: This is not secure | |
| sql = params.map { |k,v| "#{k} = #{v.inspect}" }.join(", ") | |
| # BrokenRecord.database is just an instance of Sqlite::Database | |
| BrokenRecord.database.execute %{ | |
| update #{@table_name} | |
| set #{sql} | |
| where id = #{id} | |
| } | |
| end |
Author
@steveklabnik: Yeah, that works just fine for inserts, the problem is that I haven't sorted out how to do it with updates, because ? = ? seems to be invalid syntax.
Ahhhhhhh. My bad.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you use ?s in the query and pass an array:
http://stackoverflow.com/questions/6231740/inserting-with-multiple-parameters-gives-sqlite3rangeexception