aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-02-13 02:34:52 +0900
committerJeremy Daer <jeremydaer@gmail.com>2017-02-12 19:52:58 -0700
commit42ed16a987c91dcb1705a414b5da15c5275e2b16 (patch)
tree695dd8ef4a8f14939e6971199126353b8d028e7c /activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
parentbb45fa05d1681230764af023058af65142c75cff (diff)
downloadrails-42ed16a987c91dcb1705a414b5da15c5275e2b16.tar.gz
rails-42ed16a987c91dcb1705a414b5da15c5275e2b16.tar.bz2
rails-42ed16a987c91dcb1705a414b5da15c5275e2b16.zip
Schema dumping support for PostgreSQL interval type
Closes #27979
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index 203566c91b..89d595eef5 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -109,6 +109,7 @@ module ActiveRecord
bit: { name: "bit" },
bit_varying: { name: "bit varying" },
money: { name: "money" },
+ interval: { name: "interval" },
}
OID = PostgreSQL::OID #:nodoc:
@@ -486,8 +487,10 @@ module ActiveRecord
m.register_type "polygon", OID::SpecializedString.new(:polygon)
m.register_type "circle", OID::SpecializedString.new(:circle)
- # FIXME: why are we keeping these types as strings?
- m.alias_type "interval", "varchar"
+ m.register_type "interval" do |_, _, sql_type|
+ precision = extract_precision(sql_type)
+ OID::SpecializedString.new(:interval, precision: precision)
+ end
register_class_with_precision m, "time", Type::Time
register_class_with_precision m, "timestamp", OID::DateTime