diff options
author | Brian Hogan <brianhogan@napcs.com> | 2009-03-19 21:24:18 -0500 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-06-21 18:24:19 +0100 |
commit | b26c2c11ab47dbd4d1e26806d1e861edc7d697e0 (patch) | |
tree | bf6bcb908c51bd841aa03e571cf9837d632339ee /activerecord/test | |
parent | 21cd4c0e93fc6ac5497ada787d286c07f627e5ba (diff) | |
download | rails-b26c2c11ab47dbd4d1e26806d1e861edc7d697e0.tar.gz rails-b26c2c11ab47dbd4d1e26806d1e861edc7d697e0.tar.bz2 rails-b26c2c11ab47dbd4d1e26806d1e861edc7d697e0.zip |
Ensure table names are quoted while renaming for sqlite3 adapter [#2272 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/migration_test.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index 16861f21b1..9ff95ae842 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -635,6 +635,32 @@ if ActiveRecord::Base.connection.supports_migrations? end end + if current_adapter?(:SQLiteAdapter) + def test_rename_table_for_sqlite_should_work_with_reserved_words + begin + assert_nothing_raised do + ActiveRecord::Base.connection.rename_table :references, :old_references + ActiveRecord::Base.connection.create_table :octopuses do |t| + t.column :url, :string + end + end + + assert_nothing_raised { ActiveRecord::Base.connection.rename_table :octopuses, :references } + + # Using explicit id in insert for compatibility across all databases + con = ActiveRecord::Base.connection + assert_nothing_raised do + con.execute "INSERT INTO 'references' (#{con.quote_column_name('id')}, #{con.quote_column_name('url')}) VALUES (1, 'http://rubyonrails.com')" + end + assert_equal 'http://rubyonrails.com', ActiveRecord::Base.connection.select_value("SELECT url FROM 'references' WHERE id=1") + + ensure + ActiveRecord::Base.connection.drop_table :references + ActiveRecord::Base.connection.rename_table :old_references, :references + end + end + end + def test_rename_table begin ActiveRecord::Base.connection.create_table :octopuses do |t| |