Module: Eaco::Adapters::ActiveRecord::Compatibility::V40::Column

Defined in:
lib/eaco/adapters/active_record/compatibility/v40.rb

Overview

Patches to ActiveRecord::ConnectionAdapters::PostgreSQLColumn

Instance Method Summary collapse

Instance Method Details

#simplified_type(field_type) ⇒ Symbol

Makes simplified_type return json for jsonb columns

Parameters:

  • field_type (String)

    the database field type

Returns:

  • (Symbol)

    the simplified type


56
57
58
59
60
61
62
# File 'lib/eaco/adapters/active_record/compatibility/v40.rb', line 56

def simplified_type(field_type)
  if field_type == 'jsonb'
    :json
  else
    super
  end
end

#sql_typeString

Makes sql_type return json for jsonb columns. This is an hack to let the casting machinery in AR 4.0 keep working with the unsupported jsonb type.

Returns:

  • (String)

    the SQL type.


45
46
47
48
# File 'lib/eaco/adapters/active_record/compatibility/v40.rb', line 45

def sql_type
  orig_type = super
  orig_type == 'jsonb' ? 'json' : orig_type
end