Module: Activerecord::Multirange::Adapter
- Defined in:
- lib/activerecord-multirange/adapter.rb
Instance Method Summary collapse
- #initialize_type_map(*params) ⇒ Object
- #load_multirange_types ⇒ Object
- #native_database_types ⇒ Object
Instance Method Details
#initialize_type_map(*params) ⇒ Object
6 7 8 9 |
# File 'lib/activerecord-multirange/adapter.rb', line 6 def initialize_type_map(*params) super load_multirange_types end |
#load_multirange_types ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/activerecord-multirange/adapter.rb', line 22 def load_multirange_types initializer = ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID::TypeMapInitializer.new(type_map) query = <<-QUERY SELECT t.oid, t.typname, t.typelem, t.typdelim, t.typinput, r.rngsubtype, t.typtype, t.typbasetype FROM pg_type as t JOIN pg_range as r ON oid = "rngmultitypid"; QUERY execute_and_clear(query, "SCHEMA", []) do |records| initializer.register_multirange_type(records) end end |
#native_database_types ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/activerecord-multirange/adapter.rb', line 11 def native_database_types super.merge({ datemultirange: { name: "datemultirange" }, nummultirange: { name: "nummultirange" }, tsmultirange: { name: "tsmultirange" }, tstzmultirange: { name: "tstzmultirange" }, int4multirange: { name: "int4multirange" }, int8multirange: { name: "int8multirange" } }) end |