Class: ActiveRecord::ConnectionAdapters::PostgreSQLColumn

Inherits:
Column
  • Object
show all
Defined in:
lib/activerecord-postgres-json/activerecord.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extract_value_from_default_with_json(default) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/activerecord-postgres-json/activerecord.rb', line 26

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

.extract_value_from_default_with_jsonb(default) ⇒ Object



37
38
39
40
41
42
43
44
45
46
# File 'lib/activerecord-postgres-json/activerecord.rb', line 37

def extract_value_from_default_with_jsonb(default)
  case default
  when "'{}'::jsonb"
    '{}'
  when "'[]'::jsonb"
    '[]'
  else
    extract_value_from_default_without_jsonb(default)
  end
end

Instance Method Details

#simplified_type_with_json(field_type) ⇒ Object

Adds the json type for the column.



11
12
13
14
# File 'lib/activerecord-postgres-json/activerecord.rb', line 11

def simplified_type_with_json(field_type)
  return :json  if field_type == 'json'
  simplified_type_without_json(field_type)
end

#simplified_type_with_jsonb(field_type) ⇒ Object

Adds the json type for the column.



17
18
19
20
# File 'lib/activerecord-postgres-json/activerecord.rb', line 17

def simplified_type_with_jsonb(field_type)
  return :jsonb if field_type == 'jsonb'
  simplified_type_without_jsonb(field_type)
end