Sha256: 260e81a72c47fb2f9d027f5abc02d631baf6aee550da79c0be31c6a99ce1e1a9
Contents?: true
Size: 1.49 KB
Versions: 1
Compression:
Stored size: 1.49 KB
Contents
module Eaco module Adapters module ActiveRecord class Compatibility ## # Rails v4.0.X compatibility layer for jsonb # module V40 ## # # Sets up the OID Type Map, reloads it, hacks native database types, # and makes jsonb mimick itself as a json - for the rest of the AR # machinery to work intact. # def self.included(base) adapter = base.connection adapter.class::OID.register_type 'jsonb', adapter.class::OID::Json.new adapter.send :reload_type_map adapter.native_database_types.update(jsonb: {name: 'jsonb'}) adapter.class.parent::PostgreSQLColumn.instance_eval do include Column end end ## # Patches to ActiveRecord::ConnectionAdapters::PostgreSQLColumn # module Column ## # Makes +sql_type+ return +json+ for +jsonb+ columns # def sql_type orig_type = super orig_type == 'jsonb' ? 'json' : type end ## # Makes +simplified_type+ return +json+ for +jsonb+ columns # # @return [Symbol] # def simplified_type(field_type) if field_type == 'jsonb' :json else super end end end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
eaco-0.6.1 | lib/eaco/adapters/active_record/compatibility/v40.rb |