Skip to content

Commit

Permalink
Fixed migration from acts_as_paranoid, tweaked test data
Browse files Browse the repository at this point in the history
  • Loading branch information
varyform committed Mar 3, 2010
1 parent 62c894a commit 1941d3e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 3 additions & 4 deletions lib/acts_as_archive/base/destroy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ def copy_to_archive(conditions, import=false)
end
else
insert_cols << 'deleted_at'

insert_cols.map! { |col| connection.quote_column_name(col) }
select_cols.map! { |col| connection.quote_column_name(col) }

select_cols << "'#{Time.now.utc.to_s(:db)}'"
end

insert_cols.map! { |col| connection.quote_column_name(col) }
select_cols.map! { |col| col =~ /^\'/ ? col : connection.quote_column_name(col) }

connection.execute(%{
INSERT INTO archived_#{table_name} (#{insert_cols.join(', ')})
SELECT #{select_cols.join(', ')}
Expand Down
3 changes: 2 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def create_records(klass=Article, values={})
end
end
connection.execute(%{
INSERT INTO #{table} (#{cols.collect { |c| "#{c}" }.join(', ')})
INSERT INTO #{table} (#{cols.collect { |c| "#{connection.quote_column_name(c)}" }.join(', ')})
VALUES (#{vals.join(', ')})
})
klass.find(x)
Expand All @@ -69,6 +69,7 @@ def establish_test_db
connection.create_table(:articles) do |t|
t.string :title
t.string :body
t.boolean :read # break mysql w/o quotation
end
# Load the model
load "#{SPEC}/db/models/article.rb"
Expand Down

0 comments on commit 1941d3e

Please sign in to comment.