diff options
author | Yves Senn <yves.senn@gmail.com> | 2013-12-03 17:54:25 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2013-12-03 17:54:25 +0100 |
commit | be5527b8e8fcc25946b128fe78db10d5bee2a483 (patch) | |
tree | 22bcea749969051c6a03ee69d7e47a0d877b68b4 /activerecord | |
parent | 7c20a8b5581f1b0054cba590542960be455a027e (diff) | |
download | rails-be5527b8e8fcc25946b128fe78db10d5bee2a483.tar.gz rails-be5527b8e8fcc25946b128fe78db10d5bee2a483.tar.bz2 rails-be5527b8e8fcc25946b128fe78db10d5bee2a483.zip |
`connection.type_to_sql` returns a `String` for unmapped types.
Closes #13146.
This fixes an error when using:
```
change_colum :table, :column, :bigint, array: true
```
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG.md | 11 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/adapter_test.rb | 4 |
3 files changed, 16 insertions, 1 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 59d409d04d..936dcbb2fb 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,14 @@ +* `type_to_sql` returns a `String` for unmapped columns. This fixes an error + when using unmapped array types in PG + + Example: + + change_colum :table, :column, :bigint, array: true + + Fixes #13146. + + *Jens Fahnenbruck*, *Yves Senn* + * Fix `QueryCache` to work with nested blocks, so that it will only clear the existing cache after leaving the outer block instead of clearing it right after the inner block is finished. diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb index 6268ae4875..51a6929dab 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -690,7 +690,7 @@ module ActiveRecord column_type_sql else - type + type.to_s end end diff --git a/activerecord/test/cases/adapter_test.rb b/activerecord/test/cases/adapter_test.rb index 595edc6263..34be68a97f 100644 --- a/activerecord/test/cases/adapter_test.rb +++ b/activerecord/test/cases/adapter_test.rb @@ -178,6 +178,10 @@ module ActiveRecord result = @connection.select_all "SELECT * FROM posts" assert result.is_a?(ActiveRecord::Result) end + + test "type_to_sql returns a String for unmapped types" do + assert_equal "special_db_type", @connection.type_to_sql(:special_db_type) + end end class AdapterTestWithoutTransaction < ActiveRecord::TestCase |