jsonb_accessor 1.4.1 → 1.4.2
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/.github/workflows/ci.yml +4 -4
- data/.github/workflows/push_gem.yml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/jsonb_accessor/attribute_query_methods.rb +1 -1
- data/lib/jsonb_accessor/macro.rb +5 -1
- data/lib/jsonb_accessor/query_helper.rb +4 -4
- data/lib/jsonb_accessor/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 120f940dd7ef924ec2b795635444e5a4cb74f7f4a952684e0899d7d998af9166
|
|
4
|
+
data.tar.gz: 1e57e729d72bdd5eec71f9f037550df4667de8fd76d79452edd35eb57f673f9a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3c462840b6fc2ad2066ac098f4d5355f882f42ee8d03cbc36ee4981863a82458853597ace25804cb6b88666befae97d04d643276ee75753f1f277228f4ba0fe6
|
|
7
|
+
data.tar.gz: 8684c941ee588107771342c7fef94377f6f94c73b33d275d6deb6ea3cb56c304bf5b5c09c02b4a8880d3da9ad8eea5148e473ebf1705c92f29f0fb187ba95670
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -10,9 +10,9 @@ jobs:
|
|
|
10
10
|
lint:
|
|
11
11
|
runs-on: ubuntu-24.04
|
|
12
12
|
steps:
|
|
13
|
-
- uses: actions/checkout@
|
|
13
|
+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
14
14
|
|
|
15
|
-
- uses: ruby/setup-ruby@
|
|
15
|
+
- uses: ruby/setup-ruby@319994f95fa847cf3fb3cd3dbe89f6dcde9f178f # v1.295.0
|
|
16
16
|
with:
|
|
17
17
|
ruby-version: "3.4"
|
|
18
18
|
bundler-cache: true
|
|
@@ -53,14 +53,14 @@ jobs:
|
|
|
53
53
|
ports: ['5432:5432']
|
|
54
54
|
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
|
55
55
|
steps:
|
|
56
|
-
- uses: actions/checkout@
|
|
56
|
+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
57
57
|
|
|
58
58
|
- run: echo "gem 'activerecord', '~> ${{ matrix.activerecord }}.0'" > Gemfile.local
|
|
59
59
|
|
|
60
60
|
- if: matrix.activerecord == '6.1' # see https://github.com/rails/rails/pull/54264#issuecomment-2596149819 and https://www.ruby-lang.org/en/news/2024/12/25/ruby-3-4-0-released/#standard-library-updates and https://www.ruby-lang.org/en/news/2025/12/25/ruby-4-0-0-released/#stdlib-updates
|
|
61
61
|
run: printf "gem 'concurrent-ruby', '< 1.3.5'\ngem 'mutex_m'\ngem 'base64'\ngem 'bigdecimal'\ngem 'logger'\n" >> Gemfile.local
|
|
62
62
|
|
|
63
|
-
- uses: ruby/setup-ruby@
|
|
63
|
+
- uses: ruby/setup-ruby@319994f95fa847cf3fb3cd3dbe89f6dcde9f178f # v1.295.0
|
|
64
64
|
with:
|
|
65
65
|
ruby-version: ${{ matrix.ruby }}
|
|
66
66
|
bundler-cache: true
|
|
@@ -22,11 +22,11 @@ jobs:
|
|
|
22
22
|
ruby: ["ruby-3.4", "jruby-9.4"]
|
|
23
23
|
|
|
24
24
|
steps:
|
|
25
|
-
- uses: step-security/harden-runner@
|
|
25
|
+
- uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
|
|
26
26
|
with:
|
|
27
27
|
egress-policy: audit
|
|
28
28
|
|
|
29
|
-
- uses: actions/checkout@
|
|
29
|
+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
30
30
|
|
|
31
31
|
- if: matrix.ruby == 'jruby-9.4' # cribbed from https://github.com/ruby/psych/blob/v5.2.4/.github/workflows/push_gem.yml
|
|
32
32
|
run: |
|
|
@@ -35,9 +35,9 @@ jobs:
|
|
|
35
35
|
gem install ruby-maven rake-compiler --no-document
|
|
36
36
|
rake compile
|
|
37
37
|
|
|
38
|
-
- uses: ruby/setup-ruby@
|
|
38
|
+
- uses: ruby/setup-ruby@319994f95fa847cf3fb3cd3dbe89f6dcde9f178f # v1.295.0
|
|
39
39
|
with:
|
|
40
40
|
bundler-cache: true
|
|
41
41
|
ruby-version: ${{ matrix.ruby }}
|
|
42
42
|
|
|
43
|
-
- uses: rubygems/release-gem@
|
|
43
|
+
- uses: rubygems/release-gem@e9a6361a0b14562539327c2a02373edc56dd3169 # v1.1.4
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
## [Unreleased]
|
|
3
3
|
|
|
4
|
+
## [1.4.2] - 2026-03-20
|
|
5
|
+
### Fixed
|
|
6
|
+
- Bug fix: Persisted records with sparse JSONB data returned `nil` instead of declared defaults for fields absent from the column. This regression was introduced in 1.4.1 during the `prefix`/`suffix` refactor, where `options.delete(:default)` mutated the options hash before passing it to `attribute`, stripping the default from the virtual attribute definition.
|
|
7
|
+
|
|
8
|
+
### Changed
|
|
9
|
+
- Documented the backward-compatible positional hash syntax in `jsonb_accessor`, where definitions are passed as a plain hash (jsonb_accessor :col, { foo: :string })
|
|
10
|
+
|
|
4
11
|
## [1.4.1] - 2026-01-22
|
|
5
12
|
### Added
|
|
6
13
|
- Support for `prefix` and `suffix` options to customize attribute accessor names while preserving original keys in the JSONB column. [#173](https://github.com/madeintandem/jsonb_accessor/issues/173)
|
|
@@ -24,7 +24,7 @@ module JsonbAccessor
|
|
|
24
24
|
# <jsonb_attribute>_order scope
|
|
25
25
|
klass.define_singleton_method "#{jsonb_attribute}_order" do |*args|
|
|
26
26
|
ordering_options = args.extract_options!
|
|
27
|
-
order_by_defaults = args.
|
|
27
|
+
order_by_defaults = args.to_h { |attribute| [attribute, :asc] }
|
|
28
28
|
store_key_mapping = all.model.public_send(store_key_mapping_method_name)
|
|
29
29
|
|
|
30
30
|
order_by_defaults.merge(ordering_options).reduce(all) do |query, (name, direction)|
|
data/lib/jsonb_accessor/macro.rb
CHANGED
|
@@ -4,6 +4,10 @@ module JsonbAccessor
|
|
|
4
4
|
module Macro
|
|
5
5
|
module ClassMethods
|
|
6
6
|
def jsonb_accessor(jsonb_attribute, global_options = {}, **definitions)
|
|
7
|
+
# Backward compatibility: support the old positional hash syntax where definitions
|
|
8
|
+
# are passed as a plain hash (jsonb_accessor :col, { foo: :string })
|
|
9
|
+
definitions = global_options if global_options.present? && definitions.blank?
|
|
10
|
+
|
|
7
11
|
names_and_store_keys = {}
|
|
8
12
|
names_and_defaults = {}
|
|
9
13
|
names_and_attribute_names = {}
|
|
@@ -14,7 +18,7 @@ module JsonbAccessor
|
|
|
14
18
|
|
|
15
19
|
# Determine store keys and default values for each field
|
|
16
20
|
names_and_store_keys[name.to_s] = (options.delete(:store_key) || name).to_s
|
|
17
|
-
names_and_defaults[name.to_s] = options
|
|
21
|
+
names_and_defaults[name.to_s] = options[:default] unless options[:default].nil?
|
|
18
22
|
|
|
19
23
|
prefix = options.delete(:prefix) || global_options[:prefix]
|
|
20
24
|
suffix = options.delete(:suffix) || global_options[:suffix]
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
module JsonbAccessor
|
|
4
4
|
module QueryHelper
|
|
5
5
|
# Errors
|
|
6
|
-
InvalidColumnName
|
|
7
|
-
InvalidFieldName
|
|
8
|
-
InvalidDirection
|
|
9
|
-
NotSupported
|
|
6
|
+
class InvalidColumnName < StandardError; end
|
|
7
|
+
class InvalidFieldName < StandardError; end
|
|
8
|
+
class InvalidDirection < StandardError; end
|
|
9
|
+
class NotSupported < StandardError; end
|
|
10
10
|
|
|
11
11
|
# Constants
|
|
12
12
|
GREATER_THAN = ">"
|