aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/postgresql/column.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-04-12 21:27:12 +0900
committerRyuta Kamizono <kamipo@gmail.com>2019-04-12 22:03:23 +0900
commit59d32a6eab144b808bdd9d96b6e6c2dc32e66f32 (patch)
treea204d84385a731731fbe363606b9d97c3748f019 /activerecord/lib/active_record/connection_adapters/postgresql/column.rb
parent3bd534287139549cee10e10364344d66139d9237 (diff)
downloadrails-59d32a6eab144b808bdd9d96b6e6c2dc32e66f32.tar.gz
rails-59d32a6eab144b808bdd9d96b6e6c2dc32e66f32.tar.bz2
rails-59d32a6eab144b808bdd9d96b6e6c2dc32e66f32.zip
Refactor around sql_type metadata and column
* remove useless `@type_metadata` and `@array` * move the compatibility code (for array) into column * etc.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql/column.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/column.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/column.rb b/activerecord/lib/active_record/connection_adapters/postgresql/column.rb
index ef98d2b37a..ec25bb1e19 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/column.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/column.rb
@@ -4,8 +4,7 @@ module ActiveRecord
module ConnectionAdapters
module PostgreSQL
class Column < ConnectionAdapters::Column # :nodoc:
- delegate :array, :oid, :fmod, to: :sql_type_metadata
- alias :array? :array
+ delegate :oid, :fmod, to: :sql_type_metadata
def initialize(*, serial: nil, **)
super
@@ -15,6 +14,15 @@ module ActiveRecord
def serial?
@serial
end
+
+ def array
+ sql_type_metadata.sql_type.end_with?("[]")
+ end
+ alias :array? :array
+
+ def sql_type
+ super.sub(/\[\]\z/, "")
+ end
end
end
PostgreSQLColumn = PostgreSQL::Column # :nodoc: