diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2015-01-30 14:25:52 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2015-02-08 19:09:04 +0900 |
commit | b199012c4f01693f18e2143f43c1bf928bae1860 (patch) | |
tree | 32dfddb4ea32bad101c8a5ffae398c1fb99e597d /activerecord | |
parent | 1492e83e49f74b1d874585000bad5368d9f09218 (diff) | |
download | rails-b199012c4f01693f18e2143f43c1bf928bae1860.tar.gz rails-b199012c4f01693f18e2143f43c1bf928bae1860.tar.bz2 rails-b199012c4f01693f18e2143f43c1bf928bae1860.zip |
An array type is a part of `sql_type`
`sql_type` is reused in `lookup_cast_type`. If making it a part of
`sql_type` when handled array option first, it isn't necessary to do
again.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_creation.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb | 21 |
2 files changed, 4 insertions, 19 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_creation.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_creation.rb index db20b60d60..81f8615976 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_creation.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_creation.rb @@ -28,7 +28,7 @@ module ActiveRecord end def visit_ColumnDefinition(o) - o.sql_type = type_to_sql(o.type, o.limit, o.precision, o.scale) + o.sql_type ||= type_to_sql(o.type, o.limit, o.precision, o.scale) column_sql = "#{quote_column_name(o.name)} #{o.sql_type}" add_column_options!(column_sql, column_options(o)) unless o.type == :primary_key column_sql diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb index d4e183dd16..750eaeca92 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb @@ -4,16 +4,9 @@ module ActiveRecord class SchemaCreation < AbstractAdapter::SchemaCreation private - def column_options(o) - column_options = super - column_options[:array] = o.array - column_options - end - - def add_column_options!(sql, options) - if options[:array] - sql << '[]' - end + def visit_ColumnDefinition(o) + o.sql_type = type_to_sql(o.type, o.limit, o.precision, o.scale) + o.sql_type << '[]' if o.array super end @@ -24,14 +17,6 @@ module ActiveRecord super end end - - def type_for_column(column) - if column.array - @conn.lookup_cast_type("#{column.sql_type}[]") - else - super - end - end end module SchemaStatements |