Created
October 9, 2013 10:04
-
-
Save skojin/6899009 to your computer and use it in GitHub Desktop.
SQL UPDATE with IGNORE keyword http://dev.mysql.com/doc/refman/5.0/en/update.html
This file contains 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
module UpdateIgnore | |
def update_ignore(updates, conditions) | |
set = updates.map{|k,v| "#{connection.quote_column_name(k)} = #{connection.quote v}" }.join(', ') | |
connection.update "UPDATE IGNORE #{quoted_table_name} SET #{set} WHERE #{self.where(conditions).where_clauses.join('AND')}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment