Class: ActiveRecord::ConnectionAdapters::PostgreSQLColumn

Inherits:
Column
  • Object
show all
Defined in:
lib/ardb/pg_json.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extract_value_from_default_with_json(default) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'lib/ardb/pg_json.rb', line 30

def extract_value_from_default_with_json(default)
  case default
  when "'{}'::json", "'{}'::jsonb"
    '{}'
  when "'[]'::json", "'[]'::jsonb"
    '[]'
  else
    extract_value_from_default_without_json(default)
  end
end

Instance Method Details

#simplified_type_with_json(field_type) ⇒ Object

Adds the json type for the column.



16
17
18
19
20
21
22
23
24
25
# File 'lib/ardb/pg_json.rb', line 16

def simplified_type_with_json(field_type)
  case field_type
  when 'json'
    :json
  when 'jsonb'
    :jsonb
  else
    simplified_type_without_json(field_type)
  end
end