Commit 2104011bf65fd8d79b8ea710e9960b88ea5ea2ca
1 parent
d9aa9757
Exists in
master
and in
22 other branches
Fix migration to generate proper SQL
(ActionItem1733)
Showing
1 changed file
with
1 additions
and
1 deletions
Show diff stats
db/migrate/20101202205446_remove_published_articles.rb
... | ... | @@ -3,7 +3,7 @@ class RemovePublishedArticles < ActiveRecord::Migration |
3 | 3 | select_all("SELECT * from articles WHERE type = 'PublishedArticle'").each do |published| |
4 | 4 | reference = Article.exists?(published['reference_article_id']) ? Article.find(published['reference_article_id']) : nil |
5 | 5 | if reference |
6 | - execute("UPDATE articles SET type = '#{reference.type}', abstract = '#{reference.abstract}', body = '#{reference.body}' WHERE articles.id = #{published['id']}") | |
6 | + execute(ActiveRecord::Base.sanitize_sql(["UPDATE articles SET type = ?, abstract = ?, body = ? WHERE articles.id = ?", reference.type, reference.abstract, reference.body, published['id']])) | |
7 | 7 | else |
8 | 8 | execute("DELETE from articles where articles.id = #{published['id']}") |
9 | 9 | end | ... | ... |