activerecord-postgres-json 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8994f61e8f3c2f0f62053662313b5d928879f696
4
- data.tar.gz: 9639c733f8fd8b282362f13ed8c72165740ece83
2
+ SHA256:
3
+ metadata.gz: 407ecfb24032a8c34bce6bc34eb02e6ce4845b13ea1d663b41476d8cb59fa3f4
4
+ data.tar.gz: 1c8e108f8126b9831b20d8f78f2ccac0d00857b4f3c573345d6ebacaa727b43c
5
5
  SHA512:
6
- metadata.gz: 299e502fedc17e9ddece9b00a26c55d56d32f0ba3259ab570a6ccabde3dcea7e53a368c4227d389b39bd6d3288512af5085e87a26ea318343df3a0fe3fa18bce
7
- data.tar.gz: 5be62b5062003837686dd6adc6f621fcbf8ed92bf1fb7c654bd8d87e73d63496acd992c3b7da849507b8b04802200f5aae5409d4b857fc5b478bf2fd72425034
6
+ metadata.gz: f497075d5d89ff8b487d5dd13246cf11ec222d4b681f67b8a48c136f5b3cce4f1fe0edb2bbafe4b6be31630db8e34eca19ad56be72e80eca0415af8542a5329e
7
+ data.tar.gz: 8061bde4477a992fc2dbac854c2c378f88278eba07c97b531b76f36f3acc70bccd89f75449105a95efbcbceca882a555ffdec4a7eb14178a00674afcb9d36df0
@@ -4,7 +4,7 @@ LineLength:
4
4
  HashSyntax:
5
5
  EnforcedStyle: ruby19
6
6
 
7
- SingleSpaceBeforeFirstArg:
7
+ Layout/SpaceBeforeFirstArg:
8
8
  Enabled: false
9
9
 
10
10
  Metrics/AbcSize:
@@ -19,8 +19,9 @@ Metrics/ClassLength:
19
19
  Metrics/MethodLength:
20
20
  Max: 20
21
21
 
22
- TrailingComma:
22
+ Naming/FileName:
23
23
  Enabled: false
24
+
24
25
  AllCops:
25
26
  Exclude:
26
27
  - '**/*.gemspec'
data/Gemfile CHANGED
@@ -1,16 +1,18 @@
1
- source 'http://rubygems.org'
1
+ # frozen_string_literal: true
2
2
 
3
- gem 'activerecord', '>= 3.2', '< 4'
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'activerecord', '>= 3.2', '< 4.2'
4
6
  gem 'multi_json'
5
7
 
6
8
  group :development, :test do
7
- gem 'rspec', '~> 2.0'
8
- gem 'pg'
9
+ gem 'pg', '~> 0.20.0'
10
+ gem 'rspec'
9
11
  end
10
12
 
11
13
  group :development do
12
- gem 'rubocop'
13
- gem 'rdoc'
14
14
  gem 'bundler'
15
15
  gem 'jeweler'
16
+ gem 'rdoc'
17
+ gem 'rubocop'
16
18
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -2,18 +2,18 @@
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.1 ruby lib
5
+ # stub: activerecord-postgres-json 0.2.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
- s.name = "activerecord-postgres-json"
9
- s.version = "0.2.1"
8
+ s.name = "activerecord-postgres-json".freeze
9
+ s.version = "0.2.2"
10
10
 
11
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
- s.require_paths = ["lib"]
13
- s.authors = ["Roman Shterenzon"]
14
- s.date = "2015-01-16"
15
- s.description = "Active Record support for PostgreSQL JSON type"
16
- s.email = "romanbsd@yahoo.com"
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib".freeze]
13
+ s.authors = ["Roman Shterenzon".freeze]
14
+ s.date = "2020-09-14"
15
+ s.description = "Active Record support for PostgreSQL JSON type".freeze
16
+ s.email = "romanbsd@yahoo.com".freeze
17
17
  s.extra_rdoc_files = [
18
18
  "LICENSE.txt",
19
19
  "README.md"
@@ -37,42 +37,33 @@ Gem::Specification.new do |s|
37
37
  "spec/spec_helper.rb",
38
38
  "spec/support/database_setup.rb"
39
39
  ]
40
- s.homepage = "http://github.com/romanbsd/activerecord-postgres-json"
41
- s.licenses = ["MIT"]
42
- s.rubygems_version = "2.4.3"
43
- s.summary = "Active Record support for PostgreSQL JSON type"
40
+ s.homepage = "http://github.com/romanbsd/activerecord-postgres-json".freeze
41
+ s.licenses = ["MIT".freeze]
42
+ s.rubygems_version = "3.1.2".freeze
43
+ s.summary = "Active Record support for PostgreSQL JSON type".freeze
44
44
 
45
45
  if s.respond_to? :specification_version then
46
46
  s.specification_version = 4
47
+ end
47
48
 
48
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
- s.add_runtime_dependency(%q<activerecord>, ["< 4", ">= 3.2"])
50
- s.add_runtime_dependency(%q<multi_json>, [">= 0"])
51
- s.add_development_dependency(%q<rspec>, ["~> 2.0"])
52
- s.add_development_dependency(%q<pg>, [">= 0"])
53
- s.add_development_dependency(%q<rubocop>, [">= 0"])
54
- s.add_development_dependency(%q<rdoc>, [">= 0"])
55
- s.add_development_dependency(%q<bundler>, [">= 0"])
56
- s.add_development_dependency(%q<jeweler>, [">= 0"])
57
- else
58
- s.add_dependency(%q<activerecord>, ["< 4", ">= 3.2"])
59
- s.add_dependency(%q<multi_json>, [">= 0"])
60
- s.add_dependency(%q<rspec>, ["~> 2.0"])
61
- s.add_dependency(%q<pg>, [">= 0"])
62
- s.add_dependency(%q<rubocop>, [">= 0"])
63
- s.add_dependency(%q<rdoc>, [">= 0"])
64
- s.add_dependency(%q<bundler>, [">= 0"])
65
- s.add_dependency(%q<jeweler>, [">= 0"])
66
- end
49
+ if s.respond_to? :add_runtime_dependency then
50
+ s.add_runtime_dependency(%q<activerecord>.freeze, [">= 3.2", "< 4.2"])
51
+ s.add_runtime_dependency(%q<multi_json>.freeze, [">= 0"])
52
+ s.add_development_dependency(%q<pg>.freeze, ["~> 0.20.0"])
53
+ s.add_development_dependency(%q<rspec>.freeze, [">= 0"])
54
+ s.add_development_dependency(%q<bundler>.freeze, [">= 0"])
55
+ s.add_development_dependency(%q<jeweler>.freeze, [">= 0"])
56
+ s.add_development_dependency(%q<rdoc>.freeze, [">= 0"])
57
+ s.add_development_dependency(%q<rubocop>.freeze, [">= 0"])
67
58
  else
68
- s.add_dependency(%q<activerecord>, ["< 4", ">= 3.2"])
69
- s.add_dependency(%q<multi_json>, [">= 0"])
70
- s.add_dependency(%q<rspec>, ["~> 2.0"])
71
- s.add_dependency(%q<pg>, [">= 0"])
72
- s.add_dependency(%q<rubocop>, [">= 0"])
73
- s.add_dependency(%q<rdoc>, [">= 0"])
74
- s.add_dependency(%q<bundler>, [">= 0"])
75
- s.add_dependency(%q<jeweler>, [">= 0"])
59
+ s.add_dependency(%q<activerecord>.freeze, [">= 3.2", "< 4.2"])
60
+ s.add_dependency(%q<multi_json>.freeze, [">= 0"])
61
+ s.add_dependency(%q<pg>.freeze, ["~> 0.20.0"])
62
+ s.add_dependency(%q<rspec>.freeze, [">= 0"])
63
+ s.add_dependency(%q<bundler>.freeze, [">= 0"])
64
+ s.add_dependency(%q<jeweler>.freeze, [">= 0"])
65
+ s.add_dependency(%q<rdoc>.freeze, [">= 0"])
66
+ s.add_dependency(%q<rubocop>.freeze, [">= 0"])
76
67
  end
77
68
  end
78
69
 
@@ -1,4 +1,6 @@
1
- ActiveSupport.on_load :active_record do # rubocop:disable Style/FileName
1
+ # frozen_string_literal: true
2
+
3
+ ActiveSupport.on_load :active_record do
2
4
  require 'activerecord-postgres-json/activerecord'
3
5
  end
4
6
  require 'activerecord-postgres-json/coders'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_record'
2
4
  require 'active_record/connection_adapters/postgresql_adapter'
3
5
 
@@ -6,6 +8,14 @@ module ActiveRecord
6
8
  PostgreSQLAdapter::NATIVE_DATABASE_TYPES[:json] = { name: 'json' }
7
9
  PostgreSQLAdapter::NATIVE_DATABASE_TYPES[:jsonb] = { name: 'jsonb' }
8
10
 
11
+ if ::ActiveRecord.version >= Gem::Version.new('4.0.0')
12
+ # As suggested here: http://www.innovationontherun.com/fixing-unknown-oid-geography-errors-with-postgis-and-rails-4-0/
13
+ # to prevent the Rails 4.0/4.1 error of
14
+ # "unknown OID: {field}"
15
+ PostgreSQLAdapter::OID.register_type('json', PostgreSQLAdapter::OID::Identity.new)
16
+ PostgreSQLAdapter::OID.register_type('jsonb', PostgreSQLAdapter::OID::Identity.new)
17
+ end
18
+
9
19
  class PostgreSQLColumn < Column
10
20
  # Adds the json type for the column.
11
21
  def simplified_type_with_json(field_type)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'multi_json'
2
4
 
3
5
  module ActiveRecord
@@ -14,7 +16,8 @@ module ActiveRecord
14
16
  def initialize(params = {})
15
17
  @default = {}
16
18
  return unless params.class.name == 'Hash'
17
- @default = params[:default] if params[:default]
19
+
20
+ @default = params[:default] if params[:default]
18
21
  @symbolize_keys = params[:symbolize_keys] if params[:symbolize_keys]
19
22
  end
20
23
 
@@ -31,7 +31,7 @@ describe 'ActiverecordPostgresJson', db: true do
31
31
  data ->> 'title' AS title,
32
32
  data #>> '{author,name}' AS author_name,
33
33
  data #>> '{author,email}' AS author_email,
34
- (data ->> 'tags')::json AS tags,
34
+ (data ->> 'tags')::jsonb AS tags,
35
35
  (data ->> 'draft')::boolean AS draft
36
36
  FROM posts
37
37
  SQL
@@ -1,5 +1,6 @@
1
1
  require 'logger'
2
2
  require 'pg'
3
+ require 'yaml'
3
4
 
4
5
  db_config = YAML.load_file(File.expand_path('../../database.yml', __FILE__))
5
6
 
@@ -19,4 +20,4 @@ rescue Exception => e
19
20
  ensure
20
21
  ActiveRecord::Base.logger = Logger.new(STDOUT)
21
22
  ActiveRecord::Base.logger.formatter = ->(_, _, _, msg) { "#{msg}\n" }
22
- end
23
+ end
metadata CHANGED
@@ -1,35 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-postgres-json
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Shterenzon
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-16 00:00:00.000000000 Z
11
+ date: 2020-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "<"
18
- - !ruby/object:Gem::Version
19
- version: '4'
20
17
  - - ">="
21
18
  - !ruby/object:Gem::Version
22
19
  version: '3.2'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '4.2'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - "<"
28
- - !ruby/object:Gem::Version
29
- version: '4'
30
27
  - - ">="
31
28
  - !ruby/object:Gem::Version
32
29
  version: '3.2'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '4.2'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: multi_json
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -45,21 +45,21 @@ dependencies:
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0'
47
47
  - !ruby/object:Gem::Dependency
48
- name: rspec
48
+ name: pg
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '2.0'
53
+ version: 0.20.0
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '2.0'
60
+ version: 0.20.0
61
61
  - !ruby/object:Gem::Dependency
62
- name: pg
62
+ name: rspec
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - ">="
@@ -73,7 +73,7 @@ dependencies:
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  - !ruby/object:Gem::Dependency
76
- name: rubocop
76
+ name: bundler
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - ">="
@@ -87,7 +87,7 @@ dependencies:
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
89
  - !ruby/object:Gem::Dependency
90
- name: rdoc
90
+ name: jeweler
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - ">="
@@ -101,7 +101,7 @@ dependencies:
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0'
103
103
  - !ruby/object:Gem::Dependency
104
- name: bundler
104
+ name: rdoc
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - ">="
@@ -115,7 +115,7 @@ dependencies:
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
117
  - !ruby/object:Gem::Dependency
118
- name: jeweler
118
+ name: rubocop
119
119
  requirement: !ruby/object:Gem::Requirement
120
120
  requirements:
121
121
  - - ">="
@@ -157,7 +157,7 @@ homepage: http://github.com/romanbsd/activerecord-postgres-json
157
157
  licenses:
158
158
  - MIT
159
159
  metadata: {}
160
- post_install_message:
160
+ post_install_message:
161
161
  rdoc_options: []
162
162
  require_paths:
163
163
  - lib
@@ -172,9 +172,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
172
  - !ruby/object:Gem::Version
173
173
  version: '0'
174
174
  requirements: []
175
- rubyforge_project:
176
- rubygems_version: 2.4.3
177
- signing_key:
175
+ rubygems_version: 3.1.2
176
+ signing_key:
178
177
  specification_version: 4
179
178
  summary: Active Record support for PostgreSQL JSON type
180
179
  test_files: []