declare_schema 4.0.1 → 4.0.2.pre.yr.0
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/CHANGELOG.md +14 -0
- data/Gemfile.lock +1 -1
- data/lib/declare_schema/model.rb +12 -2
- data/lib/declare_schema/version.rb +1 -1
- data/spec/lib/declare_schema/migration_generator_spec.rb +13 -7
- metadata +6 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '08fa20ab8cf59c6a2bff4cd297f7ea0416f2544d4d217e6049453e6678dc2208'
|
|
4
|
+
data.tar.gz: 266db13b805ae1e832f7d30591c439f922315c76b92ea65b5da6a1c61cc18561
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eb0668b2c858ee3d5eb0ed9b2c4317401510fb105d7ff0cfd4b901c6e20d8d91a5784979412bfc0d74803e15d94ca2d61e867314ee41b3fafefe493072d95850
|
|
7
|
+
data.tar.gz: 2e2781550cf5e33f94ae868e6b1aa5ed6c927a0c04749ff6fb6457775f32c3ddea3424558069c1e4f21b5476bfdfe2da67df2699a6b04498b13a54dc7858dbb2
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,20 @@ Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
|
4
4
|
|
|
5
5
|
Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [4.0.2] - 2026-05-26
|
|
8
|
+
### Fixed
|
|
9
|
+
- Fixed Rails 7.2 compatibility for the `serialize:` field option. Rails 7.2 changed
|
|
10
|
+
`serialize` from a positional second argument to keyword-only (`coder:` / `type:`),
|
|
11
|
+
causing an `ArgumentError` in any app using `serialize: Array`, `serialize: Hash`,
|
|
12
|
+
`serialize: JSON`, or a custom coder. The fix branches on Rails version and uses
|
|
13
|
+
the correct keyword API for Rails ≥ 7.2:
|
|
14
|
+
- `serialize: true` → `serialize(attr, coder: ::YAML)`
|
|
15
|
+
- `serialize: Array` / `serialize: Hash` → `serialize(attr, coder: ::YAML, type: ClassName)`
|
|
16
|
+
- `serialize: JSON` → `serialize(attr, coder: JSON)`
|
|
17
|
+
- `serialize: MyCoder` (custom coder) → `serialize(attr, coder: MyCoder)`
|
|
18
|
+
Note: `::YAML` is used explicitly rather than relying on `default_column_serializer`,
|
|
19
|
+
which is `nil` by default in Rails 7.2 apps using `load_defaults 7.2`.
|
|
20
|
+
|
|
7
21
|
## [4.0.1] - 2026-05-07
|
|
8
22
|
### Fixed
|
|
9
23
|
- `DeferredFieldSpec` (the lazy stand-in introduced in 4.0.0 for `belongs_to`
|
data/Gemfile.lock
CHANGED
data/lib/declare_schema/model.rb
CHANGED
|
@@ -477,8 +477,18 @@ module DeclareSchema
|
|
|
477
477
|
def _add_serialize_for_field(name, type, options)
|
|
478
478
|
if (serialize_class = options.delete(:serialize))
|
|
479
479
|
type == :string || type == :text or raise ArgumentError, "serialize field type must be :string or :text"
|
|
480
|
-
|
|
481
|
-
|
|
480
|
+
if ActiveRecord.gem_version >= Gem::Version.new('7.2')
|
|
481
|
+
if serialize_class == true
|
|
482
|
+
serialize(name, coder: ::YAML)
|
|
483
|
+
elsif serialize_class.respond_to?(:load)
|
|
484
|
+
serialize(name, coder: serialize_class)
|
|
485
|
+
else
|
|
486
|
+
serialize(name, coder: ::YAML, type: serialize_class)
|
|
487
|
+
end
|
|
488
|
+
else
|
|
489
|
+
serialize_args = Array((serialize_class unless serialize_class == true))
|
|
490
|
+
serialize(name, *serialize_args)
|
|
491
|
+
end
|
|
482
492
|
if options.has_key?(:default)
|
|
483
493
|
options[:default] = _serialized_default(name, serialize_class == true ? Object : serialize_class, options[:default])
|
|
484
494
|
end
|
|
@@ -1295,8 +1295,8 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
|
1295
1295
|
class << self
|
|
1296
1296
|
attr_reader :serialize_args
|
|
1297
1297
|
|
|
1298
|
-
def serialize(*args)
|
|
1299
|
-
@serialize_args << args
|
|
1298
|
+
def serialize(*args, **kwargs)
|
|
1299
|
+
@serialize_args << (kwargs.empty? ? args : [*args, kwargs])
|
|
1300
1300
|
end
|
|
1301
1301
|
end
|
|
1302
1302
|
end
|
|
@@ -1310,7 +1310,8 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
|
1310
1310
|
end
|
|
1311
1311
|
end
|
|
1312
1312
|
|
|
1313
|
-
|
|
1313
|
+
expected = ActiveRecord.gem_version >= Gem::Version.new('7.2') ? [[:allow_list, { coder: ::YAML }]] : [[:allow_list]]
|
|
1314
|
+
expect(Ad.serialize_args).to eq(expected)
|
|
1314
1315
|
end
|
|
1315
1316
|
|
|
1316
1317
|
it 'converts defaults with .to_yaml' do
|
|
@@ -1338,9 +1339,11 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
|
1338
1339
|
end
|
|
1339
1340
|
end
|
|
1340
1341
|
|
|
1341
|
-
|
|
1342
|
+
expected = ActiveRecord.gem_version >= Gem::Version.new('7.2') ? [[:allow_list, { coder: ::YAML, type: Array }]] : [[:allow_list, Array]]
|
|
1343
|
+
expect(Ad.serialize_args).to eq(expected)
|
|
1342
1344
|
end
|
|
1343
1345
|
|
|
1346
|
+
|
|
1344
1347
|
it 'allows Array defaults' do
|
|
1345
1348
|
class Ad < ActiveRecord::Base # rubocop:disable Lint/ConstantDefinitionInBlock
|
|
1346
1349
|
declare_schema do
|
|
@@ -1366,7 +1369,8 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
|
1366
1369
|
end
|
|
1367
1370
|
end
|
|
1368
1371
|
|
|
1369
|
-
|
|
1372
|
+
expected = ActiveRecord.gem_version >= Gem::Version.new('7.2') ? [[:allow_list, { coder: ::YAML, type: Hash }]] : [[:allow_list, Hash]]
|
|
1373
|
+
expect(Ad.serialize_args).to eq(expected)
|
|
1370
1374
|
end
|
|
1371
1375
|
|
|
1372
1376
|
it 'allows Hash defaults' do
|
|
@@ -1392,7 +1396,8 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
|
1392
1396
|
end
|
|
1393
1397
|
end
|
|
1394
1398
|
|
|
1395
|
-
|
|
1399
|
+
expected = ActiveRecord.gem_version >= Gem::Version.new('7.2') ? [[:allow_list, { coder: JSON }]] : [[:allow_list, JSON]]
|
|
1400
|
+
expect(Ad.serialize_args).to eq(expected)
|
|
1396
1401
|
end
|
|
1397
1402
|
|
|
1398
1403
|
it 'allows JSON defaults' do
|
|
@@ -1442,7 +1447,8 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
|
1442
1447
|
end
|
|
1443
1448
|
end
|
|
1444
1449
|
|
|
1445
|
-
|
|
1450
|
+
expected = ActiveRecord.gem_version >= Gem::Version.new('7.2') ? [[:allow_list, { coder: ValueClass }]] : [[:allow_list, ValueClass]]
|
|
1451
|
+
expect(Ad.serialize_args).to eq(expected)
|
|
1446
1452
|
end
|
|
1447
1453
|
|
|
1448
1454
|
it 'allows ValueClass defaults' do
|
metadata
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: declare_schema
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.0.
|
|
4
|
+
version: 4.0.2.pre.yr.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Invoca Development adapted from hobo_fields by Tom Locke
|
|
8
|
+
autorequire:
|
|
8
9
|
bindir: bin
|
|
9
10
|
cert_chain: []
|
|
10
|
-
date:
|
|
11
|
+
date: 2026-05-27 00:00:00.000000000 Z
|
|
11
12
|
dependencies:
|
|
12
13
|
- !ruby/object:Gem::Dependency
|
|
13
14
|
name: rails
|
|
@@ -143,6 +144,7 @@ homepage: https://github.com/Invoca/declare_schema
|
|
|
143
144
|
licenses: []
|
|
144
145
|
metadata:
|
|
145
146
|
allowed_push_host: https://rubygems.org
|
|
147
|
+
post_install_message:
|
|
146
148
|
rdoc_options: []
|
|
147
149
|
require_paths:
|
|
148
150
|
- lib
|
|
@@ -157,7 +159,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
157
159
|
- !ruby/object:Gem::Version
|
|
158
160
|
version: 1.3.6
|
|
159
161
|
requirements: []
|
|
160
|
-
rubygems_version: 3.
|
|
162
|
+
rubygems_version: 3.5.22
|
|
163
|
+
signing_key:
|
|
161
164
|
specification_version: 4
|
|
162
165
|
summary: Database schema declaration and migration generator for Rails
|
|
163
166
|
test_files: []
|