jsonb_accessor 1.3.10 → 1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5593f84fe3d0e2038beeac5377fef22f4d1b1b18daf78b3f65dc4c55362592e0
4
- data.tar.gz: 3421f8ce790d9ca3db6f93007ce3a0ca327a749073f6f8df36f7fb922f5485af
3
+ metadata.gz: 6e76b0bf2b54d9887af7fd350b39c958817b7c5633513962f1fb6620f397e017
4
+ data.tar.gz: 862e5b32701dcccb72e4cc722671c907072414bc8dc2a747a0df84650f79e623
5
5
  SHA512:
6
- metadata.gz: a1433289f8c96cd0105f9b49922a4771c99a886f593b79225c835850d6875fad420fd91c60f6c05844464ae757ff597ec1a287245c75bf1afb823fff457eb33a
7
- data.tar.gz: 9b3af34ed491b630e2e0f5859e263cbd157a2d7c6d29713d8536a7e389a21dc356a70e2b70ec3b207cb42c26814736e1fe984e3201acd34e58b08813d5a1a2fd
6
+ metadata.gz: '08f23e84686da1f3ae4c475e159ea2815323cc6f08a8549890f42b3e7a044c0f0867a5c70171084633f9feb898e23b67bc612672b5276fb256dd48adb3d279cd'
7
+ data.tar.gz: 834b8130f8046c965131ca88049b39e1a675ba02b4d4637b622db0b2da84e1b556090482697929e665eb03d3eb867da95fc31171d9c9b2b8669f3449975b2a95
@@ -24,7 +24,7 @@ jobs:
24
24
  needs: lint
25
25
  services:
26
26
  db:
27
- image: postgres:9.4
27
+ image: postgres
28
28
  env:
29
29
  POSTGRES_HOST_AUTH_METHOD: trust
30
30
  POSTGRES_DB: jsonb_accessor
@@ -36,99 +36,40 @@ jobs:
36
36
  fail-fast: false
37
37
  matrix:
38
38
  include:
39
- - gemfile: activerecord_5.0.0
40
- ruby: '2.4'
41
-
42
- - gemfile: activerecord_5.1.0
43
- ruby: '2.4'
44
-
45
- - gemfile: activerecord_5.2.0
46
- ruby: '2.4'
47
-
48
- - gemfile: activerecord_5.0.0
49
- ruby: '2.5'
50
-
51
- - gemfile: activerecord_5.1.0
52
- ruby: '2.5'
53
-
54
- - gemfile: activerecord_5.2.0
55
- ruby: '2.5'
56
-
57
- - gemfile: activerecord_6.0.0
58
- ruby: '2.5'
59
-
60
- - gemfile: activerecord_6.1.0
61
- ruby: '2.5'
62
-
63
- - gemfile: activerecord_5.0.0
64
- ruby: '2.6'
65
-
66
- - gemfile: activerecord_5.1.0
67
- ruby: '2.6'
68
-
69
- - gemfile: activerecord_5.2.0
70
- ruby: '2.6'
71
-
72
- - gemfile: activerecord_6.0.0
73
- ruby: '2.6'
74
-
75
- - gemfile: activerecord_6.1.0
76
- ruby: '2.6'
77
-
78
- - gemfile: activerecord_5.0.0
79
- ruby: '2.7'
80
-
81
- - gemfile: activerecord_5.1.0
82
- ruby: '2.7'
83
-
84
- - gemfile: activerecord_5.2.0
85
- ruby: '2.7'
86
-
87
- - gemfile: activerecord_6.0.0
88
- ruby: '2.7'
89
-
90
- - gemfile: activerecord_6.1.0
91
- ruby: '2.7'
92
-
93
- - gemfile: activerecord_7.0.1
94
- ruby: '2.7'
95
-
96
- - gemfile: activerecord_6.1.0
39
+ - gemfile: activerecord_6.1
97
40
  ruby: '3.0'
98
41
 
99
- - gemfile: activerecord_6.1.0
42
+ - gemfile: activerecord_6.1
100
43
  ruby: '3.1'
101
44
 
102
- - gemfile: activerecord_6.1.0
45
+ - gemfile: activerecord_6.1
103
46
  ruby: '3.2'
104
47
 
105
- - gemfile: activerecord_7.0.1
48
+ - gemfile: activerecord_7.0
106
49
  ruby: '3.0'
107
50
 
108
- - gemfile: activerecord_7.0.1
51
+ - gemfile: activerecord_7.0
109
52
  ruby: '3.1'
110
53
 
111
- - gemfile: activerecord_7.0.1
54
+ - gemfile: activerecord_7.0
112
55
  ruby: '3.2'
113
56
 
114
- - gemfile: activerecord_5.1.0
115
- ruby: 'jruby-9.3'
116
-
117
- - gemfile: activerecord_5.2.0
118
- ruby: 'jruby-9.3'
57
+ - gemfile: activerecord_7.1
58
+ ruby: '3.0'
119
59
 
120
- - gemfile: activerecord_6.0.0
121
- ruby: 'jruby-9.3'
60
+ - gemfile: activerecord_7.1
61
+ ruby: '3.1'
122
62
 
123
- - gemfile: activerecord_6.1.0
124
- ruby: 'jruby-9.3'
63
+ - gemfile: activerecord_7.1
64
+ ruby: '3.2'
125
65
 
126
- # waiting for https://github.com/jruby/activerecord-jdbc-adapter/issues/1125 to be addressed
127
- # - gemfile: activerecord_7.0.1
128
- # ruby: 'jruby-9.4'
66
+ - gemfile: activerecord_7.0
67
+ ruby: 'jruby-9.4'
129
68
 
130
69
  name: ${{ matrix.gemfile }}, ruby ${{ matrix.ruby }}
131
70
 
71
+ env:
72
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
132
73
  steps:
133
74
  - uses: actions/checkout@v3
134
75
 
@@ -140,8 +81,7 @@ jobs:
140
81
 
141
82
  - name: Bundle install
142
83
  run: |
143
- bundle config set gemfile "${GITHUB_WORKSPACE}/gemfiles/${{ matrix.gemfile }}.gemfile"
144
- bundle install --jobs 4 --retry 3
84
+ bundle install
145
85
 
146
86
  - name: Setup DB
147
87
  run: |
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.2.1
1
+ 3.2.2
data/Appraisals CHANGED
@@ -1,25 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- appraise "activerecord-5.0.0" do
4
- gem "activerecord", "~> 5.0.0"
5
- end
6
-
7
- appraise "activerecord-5.1.0" do
8
- gem "activerecord", "~> 5.1.3"
9
- end
10
-
11
- appraise "activerecord-5.2.0" do
12
- gem "activerecord", "~> 5.2.8"
13
- end
14
-
15
- appraise "activerecord-6.0.0" do
16
- gem "activerecord", "~> 6.0.6"
3
+ appraise "activerecord-6.1" do
4
+ gem "activerecord", "~> 6.1"
17
5
  end
18
6
 
19
- appraise "activerecord-6.1.0" do
20
- gem "activerecord", "~> 6.1"
7
+ appraise "activerecord-7.0" do
8
+ gem "activerecord", "~> 7.0.8"
21
9
  end
22
10
 
23
- appraise "activerecord-7.0.1" do
24
- gem "activerecord", "~> 7.0.1"
11
+ appraise "activerecord-7.1" do
12
+ gem "activerecord", "~> 7.1"
25
13
  end
data/CHANGELOG.md CHANGED
@@ -1,6 +1,17 @@
1
1
  # Changelog
2
2
  ## [Unreleased]
3
3
 
4
+ ## [1.4] - 2023-10-15
5
+ ### Breaking change
6
+ - `jsonb_accessor` dropped support for Ruby 2 and Rails versions lower than 6.1. Support for ActiveRecord::Enum was also
7
+ dropped because ActiveRecord 7.1 now requires each enum field to be backed by a database column. Enums will still work
8
+ when using AR versions lower than 7.1. This is a limitation of Rails, not of this gem.
9
+
10
+ ### Fixed
11
+
12
+ - Bug fix: An array of datetimes previously caused an error. https://github.com/madeintandem/jsonb_accessor/pull/169. Thanks @bekicot.
13
+ - Rails 7.1 is officially supported and tested against.
14
+
4
15
  ## [1.3.10] - 2023-05-30
5
16
  ### No changes
6
17
  A new release was necessary to fix the corrupted 1.3.9 Java release on RubyGems.
data/Dockerfile CHANGED
@@ -8,5 +8,5 @@ WORKDIR /usr/src/app
8
8
 
9
9
  COPY lib/jsonb_accessor/version.rb ./lib/jsonb_accessor/version.rb
10
10
  COPY jsonb_accessor.gemspec Gemfile ./
11
- # RUN bundle install
11
+ RUN bundle install
12
12
  COPY . ./
data/README.md CHANGED
@@ -318,7 +318,8 @@ Because this gem promotes attributes nested into the JSON column to first level
318
318
 
319
319
  ## Dependencies
320
320
 
321
- - ActiveRecord >= 5.0
321
+ - Ruby > 3. Lower versions are not tested.
322
+ - ActiveRecord >= 6.1
322
323
  - Postgres >= 9.4 (in order to use the [jsonb column type](http://www.postgresql.org/docs/9.4/static/datatype-json.html)).
323
324
 
324
325
  ## Upgrading
data/bin/console CHANGED
@@ -7,7 +7,7 @@ require "rspec"
7
7
  require File.expand_path("../spec/spec_helper.rb", __dir__)
8
8
 
9
9
  dbconfig = YAML.safe_load(ERB.new(File.read(File.join("db", "config.yml"))).result, aliases: true)
10
- ActiveRecord::Base.establish_connection(dbconfig["development"])
10
+ ActiveRecord::Base.establish_connection(dbconfig["test"])
11
11
 
12
12
  # rubocop:disable Lint/UselessAssignment
13
13
  x = Product.new
data/db/config.yml CHANGED
@@ -2,7 +2,7 @@ default: &default
2
2
  adapter: postgresql
3
3
  database: jsonb_accessor
4
4
  host: <%= ENV.fetch("DATABASE_HOST") { "127.0.0.1" } %>
5
- user: postgres
5
+ username: <%= ENV.fetch("DATABASE_USER") { "postgres" } %>
6
6
 
7
7
  test:
8
8
  <<: *default
data/db/schema.rb CHANGED
@@ -1,18 +1,16 @@
1
- # frozen_string_literal: true
2
-
3
1
  # This file is auto-generated from the current state of the database. Instead
4
2
  # of editing this file, please use the migrations feature of Active Record to
5
3
  # incrementally modify your database, and then regenerate this schema definition.
6
4
  #
7
- # Note that this schema.rb definition is the authoritative source for your
8
- # database schema. If you need to create the application database on another
9
- # system, you should be using db:schema:load, not running all the migrations
10
- # from scratch. The latter is a flawed and unsustainable approach (the more migrations
11
- # you'll amass, the slower it'll run and the greater likelihood for issues).
5
+ # This file is the source Rails uses to define your schema when running `bin/rails
6
+ # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
7
+ # be faster and is potentially less error prone than running all of your
8
+ # migrations from scratch. Old migrations may fail to apply correctly if those
9
+ # migrations use external dependencies or application code.
12
10
  #
13
11
  # It's strongly recommended that you check this file into your version control system.
14
12
 
15
- ActiveRecord::Schema.define(version: 20_150_407_031_737) do
13
+ ActiveRecord::Schema.define(version: 2015_04_07_031737) do
16
14
  # These are extensions that must be enabled in order to support this database
17
15
  enable_extension "plpgsql"
18
16
 
@@ -30,7 +28,8 @@ ActiveRecord::Schema.define(version: 20_150_407_031_737) do
30
28
  t.float "float_type"
31
29
  t.time "time_type"
32
30
  t.date "date_type"
33
- t.datetime "datetime_type"
31
+ t.datetime "datetime_type", precision: nil
34
32
  t.decimal "decimal_type"
35
33
  end
34
+
36
35
  end
data/docker-compose.yml CHANGED
@@ -16,7 +16,7 @@ services:
16
16
 
17
17
 
18
18
  postgres:
19
- image: postgres:12
19
+ image: postgres
20
20
  environment:
21
21
  - POSTGRES_HOST_AUTH_METHOD=trust
22
22
  - POSTGRES_DB=jsonb_accessor
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 5.0.0"
5
+ gem "activerecord", "~> 7.0.8"
6
6
 
7
7
  gemspec path: "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 5.1.3"
5
+ gem "activerecord", "~> 7.1"
6
6
 
7
7
  gemspec path: "../"
@@ -17,24 +17,24 @@ Gem::Specification.new do |spec|
17
17
  spec.description = "Adds typed jsonb backed fields to your ActiveRecord models."
18
18
  spec.homepage = "https://github.com/devmynd/jsonb_accessor"
19
19
  spec.license = "MIT"
20
- spec.required_ruby_version = ">= 2"
20
+ spec.required_ruby_version = ">= 3"
21
21
 
22
22
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) || f.match(/png\z/) }
23
23
  spec.bindir = "exe"
24
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
25
  spec.require_paths = ["lib"]
26
26
 
27
- spec.add_dependency "activerecord", ">= 5.0"
28
- spec.add_dependency "activesupport", ">= 5.0"
27
+ spec.add_dependency "activerecord", ">= 6.1"
28
+ spec.add_dependency "activesupport", ">= 6.1"
29
29
  if is_java
30
30
  spec.add_dependency "activerecord-jdbcpostgresql-adapter", ">= 50.0"
31
31
  else
32
32
  spec.add_dependency "pg", ">= 0.18.1"
33
33
  end
34
34
 
35
- spec.add_development_dependency "appraisal", "~> 2.2.0"
35
+ spec.add_development_dependency "appraisal", "~> 2.5"
36
36
  spec.add_development_dependency "awesome_print"
37
- spec.add_development_dependency "database_cleaner", "~> 1.6.0"
37
+ spec.add_development_dependency "database_cleaner-active_record", "~> 2.1"
38
38
  spec.add_development_dependency "pry"
39
39
  spec.add_development_dependency "pry-doc"
40
40
  spec.add_development_dependency "pry-nav"
@@ -24,14 +24,23 @@ module JsonbAccessor
24
24
  return value if value.blank?
25
25
 
26
26
  if attribute_type == :datetime
27
- value = if active_record_default_timezone == :utc
28
- Time.find_zone("UTC").parse(value).in_time_zone
27
+ value = if value.is_a?(Array)
28
+ value.map { |v| parse_date(v) }
29
29
  else
30
- Time.zone.parse(value)
30
+ parse_date(value)
31
31
  end
32
32
  end
33
33
 
34
34
  value
35
35
  end
36
+
37
+ # Parse datetime based on the configured default_timezone
38
+ def parse_date(datetime)
39
+ if active_record_default_timezone == :utc
40
+ Time.find_zone("UTC").parse(datetime).in_time_zone
41
+ else
42
+ Time.zone.parse(datetime)
43
+ end
44
+ end
36
45
  end
37
46
  end
@@ -1,5 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JsonbAccessor
4
- VERSION = "1.3.10"
4
+ VERSION = "1.4"
5
+
6
+ def self.enum_support?
7
+ # From AR 7.1 on, enums require a database column.
8
+ Gem::Version.new(ActiveRecord::VERSION::STRING) < Gem::Version.new("7.1")
9
+ end
5
10
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonb_accessor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.10
4
+ version: '1.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Crismali
8
8
  - Joe Hirn
9
9
  - Jason Haruska
10
- autorequire:
10
+ autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2023-05-31 00:00:00.000000000 Z
13
+ date: 2023-10-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -18,28 +18,28 @@ dependencies:
18
18
  requirements:
19
19
  - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: '5.0'
21
+ version: '6.1'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
- version: '5.0'
28
+ version: '6.1'
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: activesupport
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
33
  - - ">="
34
34
  - !ruby/object:Gem::Version
35
- version: '5.0'
35
+ version: '6.1'
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: '5.0'
42
+ version: '6.1'
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: pg
45
45
  requirement: !ruby/object:Gem::Requirement
@@ -60,14 +60,14 @@ dependencies:
60
60
  requirements:
61
61
  - - "~>"
62
62
  - !ruby/object:Gem::Version
63
- version: 2.2.0
63
+ version: '2.5'
64
64
  type: :development
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - "~>"
69
69
  - !ruby/object:Gem::Version
70
- version: 2.2.0
70
+ version: '2.5'
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: awesome_print
73
73
  requirement: !ruby/object:Gem::Requirement
@@ -83,19 +83,19 @@ dependencies:
83
83
  - !ruby/object:Gem::Version
84
84
  version: '0'
85
85
  - !ruby/object:Gem::Dependency
86
- name: database_cleaner
86
+ name: database_cleaner-active_record
87
87
  requirement: !ruby/object:Gem::Requirement
88
88
  requirements:
89
89
  - - "~>"
90
90
  - !ruby/object:Gem::Version
91
- version: 1.6.0
91
+ version: '2.1'
92
92
  type: :development
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
96
  - - "~>"
97
97
  - !ruby/object:Gem::Version
98
- version: 1.6.0
98
+ version: '2.1'
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: pry
101
101
  requirement: !ruby/object:Gem::Requirement
@@ -224,12 +224,9 @@ files:
224
224
  - db/migrate/20150407031737_set_up_testing_db.rb
225
225
  - db/schema.rb
226
226
  - docker-compose.yml
227
- - gemfiles/activerecord_5.0.0.gemfile
228
- - gemfiles/activerecord_5.1.0.gemfile
229
- - gemfiles/activerecord_5.2.0.gemfile
230
- - gemfiles/activerecord_6.0.0.gemfile
231
- - gemfiles/activerecord_6.1.0.gemfile
232
- - gemfiles/activerecord_7.0.1.gemfile
227
+ - gemfiles/activerecord_6.1.gemfile
228
+ - gemfiles/activerecord_7.0.gemfile
229
+ - gemfiles/activerecord_7.1.gemfile
233
230
  - jsonb_accessor.gemspec
234
231
  - lib/jsonb_accessor.rb
235
232
  - lib/jsonb_accessor/attribute_query_methods.rb
@@ -242,7 +239,7 @@ homepage: https://github.com/devmynd/jsonb_accessor
242
239
  licenses:
243
240
  - MIT
244
241
  metadata: {}
245
- post_install_message:
242
+ post_install_message:
246
243
  rdoc_options: []
247
244
  require_paths:
248
245
  - lib
@@ -250,7 +247,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
250
247
  requirements:
251
248
  - - ">="
252
249
  - !ruby/object:Gem::Version
253
- version: '2'
250
+ version: '3'
254
251
  required_rubygems_version: !ruby/object:Gem::Requirement
255
252
  requirements:
256
253
  - - ">="
@@ -258,7 +255,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
258
255
  version: '0'
259
256
  requirements: []
260
257
  rubygems_version: 3.4.10
261
- signing_key:
258
+ signing_key:
262
259
  specification_version: 4
263
260
  summary: Adds typed jsonb backed fields to your ActiveRecord models.
264
261
  test_files: []
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 5.2.8"
6
-
7
- gemspec path: "../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 6.0.6"
6
-
7
- gemspec path: "../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 7.0.1"
6
-
7
- gemspec path: "../"