Class: ActiveRecord::ConnectionAdapters::PostgreSQLAdapter

Inherits:
AbstractAdapter
  • Object
show all
Defined in:
lib/padrino-hstore/activerecord.rb

Instance Method Summary collapse

Instance Method Details

#native_database_types_with_hstoreObject



133
134
135
# File 'lib/padrino-hstore/activerecord.rb', line 133

def native_database_types_with_hstore
  native_database_types_without_hstore.merge({:hstore => { :name => "hstore" }})
end

#quote_with_hstore(value, column = nil) ⇒ Object

Quotes correctly a hstore column value.



138
139
140
141
142
143
144
# File 'lib/padrino-hstore/activerecord.rb', line 138

def quote_with_hstore(value, column = nil)
  if value && column && column.sql_type == 'hstore'
    raise HstoreTypeMismatch, "#{column.name} must have a Hash or a valid hstore value (#{value})" unless value.kind_of?(Hash) || value.valid_hstore?          
    return quote_without_hstore(value.to_hstore, column)
  end
  quote_without_hstore(value,column)
end