activerecord-postgres-json 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/activerecord-postgres-json.gemspec +2 -2
- data/lib/activerecord-postgres-json/activerecord.rb +10 -22
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8994f61e8f3c2f0f62053662313b5d928879f696
|
|
4
|
+
data.tar.gz: 9639c733f8fd8b282362f13ed8c72165740ece83
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 299e502fedc17e9ddece9b00a26c55d56d32f0ba3259ab570a6ccabde3dcea7e53a368c4227d389b39bd6d3288512af5085e87a26ea318343df3a0fe3fa18bce
|
|
7
|
+
data.tar.gz: 5be62b5062003837686dd6adc6f621fcbf8ed92bf1fb7c654bd8d87e73d63496acd992c3b7da849507b8b04802200f5aae5409d4b857fc5b478bf2fd72425034
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.2.
|
|
1
|
+
0.2.1
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
|
5
|
-
# stub: activerecord-postgres-json 0.2.
|
|
5
|
+
# stub: activerecord-postgres-json 0.2.1 ruby lib
|
|
6
6
|
|
|
7
7
|
Gem::Specification.new do |s|
|
|
8
8
|
s.name = "activerecord-postgres-json"
|
|
9
|
-
s.version = "0.2.
|
|
9
|
+
s.version = "0.2.1"
|
|
10
10
|
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
12
12
|
s.require_paths = ["lib"]
|
|
@@ -9,43 +9,31 @@ module ActiveRecord
|
|
|
9
9
|
class PostgreSQLColumn < Column
|
|
10
10
|
# Adds the json type for the column.
|
|
11
11
|
def simplified_type_with_json(field_type)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
case field_type
|
|
13
|
+
when 'json'
|
|
14
|
+
:json
|
|
15
|
+
when 'jsonb'
|
|
16
|
+
:jsonb
|
|
17
|
+
else
|
|
18
|
+
simplified_type_without_json(field_type)
|
|
19
|
+
end
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
alias_method_chain :simplified_type, :json
|
|
23
|
-
alias_method_chain :simplified_type, :jsonb
|
|
24
23
|
|
|
25
24
|
class << self
|
|
26
25
|
def extract_value_from_default_with_json(default)
|
|
27
26
|
case default
|
|
28
|
-
when "'{}'::json"
|
|
27
|
+
when "'{}'::json", "'{}'::jsonb"
|
|
29
28
|
'{}'
|
|
30
|
-
when "'[]'::json"
|
|
29
|
+
when "'[]'::json", "'[]'::jsonb"
|
|
31
30
|
'[]'
|
|
32
31
|
else
|
|
33
32
|
extract_value_from_default_without_json(default)
|
|
34
33
|
end
|
|
35
34
|
end
|
|
36
35
|
|
|
37
|
-
def extract_value_from_default_with_jsonb(default)
|
|
38
|
-
case default
|
|
39
|
-
when "'{}'::jsonb"
|
|
40
|
-
'{}'
|
|
41
|
-
when "'[]'::jsonb"
|
|
42
|
-
'[]'
|
|
43
|
-
else
|
|
44
|
-
extract_value_from_default_without_jsonb(default)
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
36
|
alias_method_chain :extract_value_from_default, :json
|
|
48
|
-
alias_method_chain :extract_value_from_default, :jsonb
|
|
49
37
|
end
|
|
50
38
|
end
|
|
51
39
|
|