未验证 提交 eabf0243 编写于 作者: R Rafael Mendonça França

Merge pull request #26089 from travisoneill/sqlite_rollback_fix

Sqlite3 Migration Error Fixed (issue #26087)
* Sqlite3 migrations to add a column to an existing table can now be
successfully rolled back when the column was given and invalid column
type.
Fixes #26087
*Travis O'Neill*
* Deprecate `sanitize_conditions`. Use `sanitize_sql` instead.
*Ryuta Kamizono*
......@@ -61,8 +69,8 @@
*Xavier Noria*
* Using `group` with an attribute that has a custom type will properly cast
the hash keys after calling a calculation method like `count`.
the hash keys after calling a calculation method like `count`.
Fixes #25595.
*Sean Griffin*
......@@ -97,7 +105,7 @@
*Sean Griffin*
* Ensure hashes can be assigned to attributes created using `composed_of`.
Fixes #25210.
*Sean Griffin*
......
......@@ -303,7 +303,7 @@ def [](name)
# end
def column(name, type, options = {})
name = name.to_s
type = type.to_sym
type = type.to_sym if type
options = options.dup
if @columns_hash[name] && @columns_hash[name].primary_key?
......
......@@ -1047,7 +1047,8 @@ def assume_migrated_upto_version(version, migrations_paths)
end
def type_to_sql(type, limit = nil, precision = nil, scale = nil) #:nodoc:
if native = native_database_types[type.to_sym]
type = type.to_sym if type
if native = native_database_types[type]
column_type_sql = (native.is_a?(Hash) ? native[:name] : native).dup
if type == :decimal # ignore limit, use precision and scale
......
......@@ -551,6 +551,23 @@ def test_create_table_with_query_from_relation
end
end
if current_adapter?(:SQLite3Adapter)
def test_allows_sqlite3_rollback_on_invalid_column_type
Person.connection.create_table :something, force: true do |t|
t.column :number, :integer
t.column :name, :string
t.column :foo, :bar
end
assert Person.connection.column_exists?(:something, :foo)
assert_nothing_raised { Person.connection.remove_column :something, :foo, :bar }
assert !Person.connection.column_exists?(:something, :foo)
assert Person.connection.column_exists?(:something, :name)
assert Person.connection.column_exists?(:something, :number)
ensure
Person.connection.drop_table :something, if_exists: true
end
end
if current_adapter? :OracleAdapter
def test_create_table_with_custom_sequence_name
# table name is 29 chars, the standard sequence name will
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册