auto_increment 1.6.2 → 1.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 14ed27569367fada694d47fa228d8d0ae3774f5388d01d292ee6bb92548591a2
4
- data.tar.gz: e360967b97bec3c8cf83b8362319f5b1622c875a7190b82ff74db43fff9983b4
3
+ metadata.gz: 0b8701c7b3e4b518cb5445dc684c249af1f2994130b0edc4ab98ef9fbfab63f7
4
+ data.tar.gz: 96eceadd52db5836d6d37ad9f672aafb166a7c2a6fc54302029b82a6c5386235
5
5
  SHA512:
6
- metadata.gz: 90558725fb565ed8dfb589c3b81210a87eb96dae11ee6252bf3fac7e664bdf9c93db378a3096caa97940de6ef5f7c0dd9c92f08f1d36e44d8431524f9de86e23
7
- data.tar.gz: e53fdeb1c95d043aa34866984c5859297c86bf6f8d66429bd1b18b6daf6b1374d979824c802a1884815df3e613930a0f4ae49853dc072e3f5406a8c0185411e1
6
+ metadata.gz: 1e320f7ea7cf46fdb0650ad3beca614dec810d49bf35915d45263597be6437842882a4c32ff658fa43ffc7b358c5a99f567bf76545fbf7c0572806c08d1f3e85
7
+ data.tar.gz: a2681a0089dd7edfece34ce71002fbd55acf5fe27222fa0421ec8a17e755f0b16f055fca4152d503f9a3aa511cf2f9647cbafecea7d6af14ea71754a4c76adc3
@@ -0,0 +1,47 @@
1
+ name: CI
2
+ on:
3
+ workflow_dispatch:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ branches:
9
+ - "*"
10
+ jobs:
11
+ standard:
12
+ runs-on: ubuntu-latest
13
+ permissions:
14
+ checks: write
15
+ contents: read
16
+ steps:
17
+ - name: Standard Ruby
18
+ uses: standardrb/standard-ruby-action@eecb3f730879f5b8830705348c2961e5aa26de78 # v1.5.0
19
+ with:
20
+ autofix: false
21
+ test:
22
+ strategy:
23
+ fail-fast: false
24
+ matrix:
25
+ ruby: ["3.3.13", "3.4.12", "4.0.9"]
26
+ gemfile: [rails_7_1, rails_7_2, rails_8_0, rails_8_1]
27
+ exclude:
28
+ - ruby: "3.3.13"
29
+ gemfile: rails_8_0
30
+ - ruby: "3.3.13"
31
+ gemfile: rails_8_1
32
+ - ruby: "4.0.9"
33
+ gemfile: rails_7_1
34
+ runs-on: ubuntu-latest
35
+ permissions:
36
+ contents: read
37
+ env:
38
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
39
+ steps:
40
+ - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
41
+ with:
42
+ persist-credentials: false
43
+ - uses: ruby/setup-ruby@b3aaceaef7e0ee231b499e7b5f49c03fc1d32199 # v1.338.0
44
+ with:
45
+ ruby-version: ${{ matrix.ruby }}
46
+ bundler-cache: true
47
+ - run: bundle exec rspec
data/.gitignore CHANGED
@@ -13,6 +13,7 @@
13
13
  !/log/.keep
14
14
  !/tmp/.keep
15
15
  /spec/db
16
+ !/spec/db/.keep
16
17
  /tags
17
18
  pkg
18
19
  *.ipr
@@ -22,4 +23,4 @@ pkg
22
23
  .byebug_history
23
24
  gemfiles/.bundle/
24
25
  .yardoc
25
- /doc
26
+ /doc
data/.rspec CHANGED
@@ -1,3 +1,2 @@
1
- --drb
2
1
  --format Fuubar
3
2
  --color
data/.rubocop.yml CHANGED
@@ -1,44 +1,10 @@
1
- Gemspec/RequiredRubyVersion:
2
- Enabled: false
3
-
4
- Metrics/AbcSize:
5
- Enabled: false
6
-
7
- Metrics/BlockLength:
8
- Enabled: false
9
-
10
- Metrics/BlockNesting:
11
- Enabled: false
12
-
13
- Metrics/ClassLength:
14
- Enabled: false
15
-
16
- Metrics/CollectionLiteralLength:
17
- Enabled: false
18
-
19
- Metrics/CyclomaticComplexity:
20
- Enabled: false
21
-
22
- Metrics/MethodLength:
23
- Enabled: false
24
-
25
- Metrics/ModuleLength:
26
- Enabled: false
27
-
28
- Metrics/ParameterLists:
29
- Enabled: false
30
-
31
- Metrics/PerceivedComplexity:
32
- Enabled: false
33
-
34
- Style/StringLiterals:
35
- Exclude:
36
- - "gemfiles/*"
37
-
38
- Style/FrozenStringLiteralComment:
39
- Exclude:
40
- - "gemfiles/*"
41
-
42
- AllCops:
43
- TargetRubyVersion: 3.2
44
- NewCops: enable
1
+ require:
2
+ - standard
3
+ - standard-custom
4
+ - standard-performance
5
+ - rubocop-performance
6
+
7
+ inherit_gem:
8
+ standard: config/base.yml
9
+ standard-custom: config/base.yml
10
+ standard-performance: config/base.yml
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.2.2
1
+ 4.0.9
data/Appraisals CHANGED
@@ -1,15 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  RAILS_VERSIONS = {
4
- '6_0' => '6.0.6.1',
5
- '6_1' => '6.1.7.6',
6
- '7_0' => '7.0.8',
7
- '7_1' => '7.1.2'
4
+ "7_1" => "7.1.6",
5
+ "7_2" => "7.2.3.1",
6
+ "8_0" => "8.0.5",
7
+ "8_1" => "8.1.3"
8
8
  }.freeze
9
9
 
10
10
  RAILS_VERSIONS.each do |name, version|
11
11
  appraise "rails_#{name}" do
12
- gem 'activerecord', version
13
- gem 'activesupport', version
12
+ gem "activerecord", version
13
+ gem "activesupport", version
14
+ group :development do
15
+ gem "standard"
16
+ end
14
17
  end
15
18
  end
data/CHANGELOG.md ADDED
@@ -0,0 +1,128 @@
1
+ # Changelog
2
+
3
+ ## [1.7.1] - 2026-11-11
4
+
5
+ ### Changed
6
+
7
+ - Updated supported Ruby versions to 3.3.13, 3.4.12, and 4.0.9
8
+ - Refreshed development dependencies and CI setup
9
+ - Clarified gem metadata, compatibility guidance, blank value handling, and the limits of database row locking
10
+
11
+ ## [1.7.0] - 2026-06-28
12
+
13
+ ### Added
14
+
15
+ - Added `lock:` option to request a database row lock when computing the next value (behavior depends on the database adapter and query; this does not guarantee uniqueness under concurrent inserts)
16
+ - Automatic type-aware default for `initial`, inferred from the database column type (`"1"` for string/text, `1` for integer)
17
+ - Deprecation warning when `initial` type doesn't match the database column type
18
+
19
+ ### Fixed
20
+
21
+ - Locked relation chaining with scopes (`lock: true` no longer breaks query chaining)
22
+ - String columns with integer `initial` now auto-detect column type and default correctly
23
+
24
+ ### Changed
25
+
26
+ - Incrementor API rewritten: `Incrementor.new(record, column, **options)` replaces the old positional hash
27
+ - Callback dispatch moved into `ActiveRecord::ClassMethods#auto_increment`
28
+ - Upgraded CI to GitHub Actions with scheduled workflow
29
+ - Added StandardRB (Ruby linting)
30
+ - Support for Ruby 3.3.5, 3.4.x, 4.0.x and Rails 7.1, 7.2, 8.0, 8.1
31
+ - Tests rewritten to verify behavior through the public API
32
+ - Bumped development dependencies (rexml, concurrent-ruby)
33
+
34
+ ## [1.6.2] - 2024-05-18
35
+
36
+ ### Fixed
37
+
38
+ - Bumped rexml from 3.2.6 to 3.2.8 for security
39
+
40
+ ## [1.6.1] - 2024-01-02
41
+
42
+ ### Changed
43
+
44
+ - Removed deprecation warning for `scope` parameter
45
+
46
+ ## [1.6.0] - 2024-01-02
47
+
48
+ ### Added
49
+
50
+ - Support for Rails 6.1.0 and 7.0.3.1
51
+
52
+ ### Deprecated
53
+
54
+ - Deprecated the legacy `scope:` option for applying model scopes, in favor of `model_scope:`. The current `scope:` option filters sequence values by matching record attributes.
55
+
56
+ ### Changed
57
+
58
+ - Migrated CI from Travis to CircleCI
59
+ - Updated supported Rails versions
60
+
61
+ ## [1.5.1] - 2019-03-14
62
+
63
+ ### Added
64
+
65
+ - Support for Rails 6
66
+
67
+ ### Changed
68
+
69
+ - Updated Ruby versions to 2.5.4 and 2.6.2
70
+
71
+ ## [1.5.0] - 2018-01-21
72
+
73
+ ### Added
74
+
75
+ - `model_scope` option to apply ActiveRecord scopes before computing the maximum value
76
+ - Support for Rails 5.2
77
+
78
+ ### Changed
79
+
80
+ - Renamed `model_scopes` to `model_scope`
81
+
82
+ ## [1.4.1] - 2017-05-04
83
+
84
+ ### Added
85
+
86
+ - Support for Rails 5.1 via Appraisal
87
+
88
+ ## [1.4.0] - 2016-11-04
89
+
90
+ ### Added
91
+
92
+ - `before:` option to choose which callback to use (`:create`, `:save`, `:validation`)
93
+ - Rubocop linting
94
+
95
+ ## [1.3.0] - 2016-07-19
96
+
97
+ ### Added
98
+
99
+ - Support for Rails 5 via Appraisal
100
+
101
+ ## [1.2.0] - 2015-06-18
102
+
103
+ ### Changed
104
+
105
+ - Breaking: arguments split into separate `column` and `options` parameters
106
+ - Lock default changed to query object
107
+
108
+ ## [1.1.1] - 2015-05-05
109
+
110
+ ### Fixed
111
+
112
+ - Minor internal cleanup
113
+
114
+ ## [1.1.0] - 2015-03-26
115
+
116
+ ### Added
117
+
118
+ - `lock:` option for thread-safe increments
119
+ - Initial implementation of scoped sequences
120
+
121
+ ## [1.0.0] - 2014-04-15
122
+
123
+ ### Added
124
+
125
+ - Initial release
126
+ - Auto-increment integer columns with `before_create` callback
127
+ - Custom starting value via `initial:` option
128
+ - `force:` option to overwrite existing values
data/Gemfile CHANGED
@@ -1,5 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source 'https://rubygems.org'
3
+ source "https://rubygems.org"
4
4
 
5
5
  gemspec
6
+
7
+ group :development do
8
+ gem "appraisal"
9
+ gem "database_cleaner"
10
+ gem "fuubar"
11
+ gem "guard"
12
+ gem "guard-rspec"
13
+ gem "rake"
14
+ gem "rspec"
15
+ gem "sqlite3", "~> 2.10.2"
16
+ gem "standard"
17
+ end
data/Gemfile.lock CHANGED
@@ -1,56 +1,61 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- auto_increment (1.6.0)
5
- activerecord (>= 6.0)
6
- activesupport (>= 6.0)
4
+ auto_increment (1.7.1)
5
+ activerecord (>= 7.1)
6
+ activesupport (>= 7.1)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activemodel (7.1.2)
12
- activesupport (= 7.1.2)
13
- activerecord (7.1.2)
14
- activemodel (= 7.1.2)
15
- activesupport (= 7.1.2)
11
+ activemodel (8.1.4.1)
12
+ activesupport (= 8.1.4.1)
13
+ activerecord (8.1.4.1)
14
+ activemodel (= 8.1.4.1)
15
+ activesupport (= 8.1.4.1)
16
16
  timeout (>= 0.4.0)
17
- activesupport (7.1.2)
17
+ activesupport (8.1.4.1)
18
18
  base64
19
19
  bigdecimal
20
- concurrent-ruby (~> 1.0, >= 1.0.2)
20
+ concurrent-ruby (~> 1.0, >= 1.3.1)
21
21
  connection_pool (>= 2.2.5)
22
22
  drb
23
23
  i18n (>= 1.6, < 2)
24
+ json
25
+ logger (>= 1.4.2)
24
26
  minitest (>= 5.1)
25
- mutex_m
26
- tzinfo (~> 2.0)
27
+ securerandom (>= 0.3)
28
+ tzinfo (~> 2.0, >= 2.0.5)
29
+ uri (>= 0.13.1)
27
30
  appraisal (2.5.0)
28
31
  bundler
29
32
  rake
30
33
  thor (>= 0.14.0)
31
- ast (2.4.2)
32
- base64 (0.2.0)
33
- bigdecimal (3.1.5)
34
+ ast (2.4.3)
35
+ base64 (0.3.0)
36
+ bigdecimal (4.1.3)
34
37
  coderay (1.1.3)
35
- concurrent-ruby (1.2.2)
36
- connection_pool (2.4.1)
37
- database_cleaner (2.0.2)
38
+ concurrent-ruby (1.3.8)
39
+ connection_pool (3.0.2)
40
+ database_cleaner (2.1.0)
38
41
  database_cleaner-active_record (>= 2, < 3)
39
- database_cleaner-active_record (2.1.0)
42
+ database_cleaner-active_record (2.2.2)
40
43
  activerecord (>= 5.a)
41
- database_cleaner-core (~> 2.0.0)
42
- database_cleaner-core (2.0.1)
43
- diff-lcs (1.5.0)
44
- drb (2.2.0)
45
- ruby2_keywords
46
- ffi (1.16.3)
47
- formatador (1.1.0)
44
+ database_cleaner-core (~> 2.0)
45
+ database_cleaner-core (2.1.0)
46
+ diff-lcs (1.6.2)
47
+ drb (2.2.3)
48
+ ffi (1.17.4)
49
+ ffi (1.17.4-x86_64-linux-gnu)
50
+ formatador (1.2.3)
51
+ reline
48
52
  fuubar (2.5.1)
49
53
  rspec-core (~> 3.0)
50
54
  ruby-progressbar (~> 1.4)
51
- guard (2.18.1)
55
+ guard (2.20.2)
52
56
  formatador (>= 0.2.4)
53
57
  listen (>= 2.7, < 4.0)
58
+ logger (~> 1.6)
54
59
  lumberjack (>= 1.0.12, < 2.0)
55
60
  nenv (~> 0.1)
56
61
  notiffany (~> 0.0)
@@ -62,94 +67,119 @@ GEM
62
67
  guard (~> 2.1)
63
68
  guard-compat (~> 1.1)
64
69
  rspec (>= 2.99.0, < 4.0)
65
- i18n (1.14.1)
70
+ i18n (1.15.2)
66
71
  concurrent-ruby (~> 1.0)
67
- json (2.7.1)
68
- language_server-protocol (3.17.0.3)
69
- listen (3.8.0)
72
+ io-console (0.9.5)
73
+ json (3.1.0)
74
+ language_server-protocol (3.17.0.6)
75
+ lint_roller (1.1.0)
76
+ listen (3.10.1)
77
+ logger
70
78
  rb-fsevent (~> 0.10, >= 0.10.3)
71
79
  rb-inotify (~> 0.9, >= 0.9.10)
72
- lumberjack (1.2.10)
73
- method_source (1.0.0)
74
- minitest (5.20.0)
75
- mutex_m (0.2.0)
80
+ logger (1.7.0)
81
+ lumberjack (1.4.2)
82
+ method_source (1.1.0)
83
+ mini_portile2 (2.8.9)
84
+ minitest (6.1.0)
85
+ drb (~> 2.0)
86
+ prism (>= 1.5, < 3)
76
87
  nenv (0.3.0)
77
88
  notiffany (0.1.3)
78
89
  nenv (~> 0.1)
79
90
  shellany (~> 0.0)
80
- parallel (1.24.0)
81
- parser (3.2.2.4)
91
+ parallel (2.3.0)
92
+ parser (3.3.13.0)
82
93
  ast (~> 2.4.1)
83
94
  racc
84
- pry (0.14.2)
95
+ prism (2.1.0)
96
+ prism (2.1.0-x86_64-linux-gnu)
97
+ pry (0.16.1)
85
98
  coderay (~> 1.1)
86
99
  method_source (~> 1.0)
87
- racc (1.7.3)
100
+ reline (>= 0.6.0)
101
+ racc (1.8.1)
88
102
  rainbow (3.1.1)
89
- rake (13.1.0)
103
+ rake (13.4.2)
90
104
  rb-fsevent (0.11.2)
91
- rb-inotify (0.10.1)
105
+ rb-inotify (0.11.1)
92
106
  ffi (~> 1.0)
93
- regexp_parser (2.8.3)
94
- rexml (3.2.8)
95
- strscan (>= 3.0.9)
96
- rspec (3.12.0)
97
- rspec-core (~> 3.12.0)
98
- rspec-expectations (~> 3.12.0)
99
- rspec-mocks (~> 3.12.0)
100
- rspec-core (3.12.2)
101
- rspec-support (~> 3.12.0)
102
- rspec-expectations (3.12.3)
107
+ regexp_parser (2.13.1)
108
+ reline (0.7.0)
109
+ io-console (~> 0.5)
110
+ rspec (3.13.2)
111
+ rspec-core (~> 3.13.0)
112
+ rspec-expectations (~> 3.13.0)
113
+ rspec-mocks (~> 3.13.0)
114
+ rspec-core (3.13.7)
115
+ rspec-support (~> 3.13.0)
116
+ rspec-expectations (3.13.6)
103
117
  diff-lcs (>= 1.2.0, < 2.0)
104
- rspec-support (~> 3.12.0)
105
- rspec-mocks (3.12.6)
118
+ rspec-support (~> 3.13.0)
119
+ rspec-mocks (3.13.9)
106
120
  diff-lcs (>= 1.2.0, < 2.0)
107
- rspec-support (~> 3.12.0)
108
- rspec-nc (0.3.0)
109
- rspec (>= 3)
110
- terminal-notifier (>= 1.4)
111
- rspec-support (3.12.1)
112
- rubocop (1.59.0)
113
- json (~> 2.3)
114
- language_server-protocol (>= 3.17.0)
115
- parallel (~> 1.10)
116
- parser (>= 3.2.2.4)
121
+ rspec-support (~> 3.13.0)
122
+ rspec-support (3.13.8)
123
+ rubocop (1.91.0)
124
+ json (>= 2.3)
125
+ language_server-protocol (~> 3.17.0.2)
126
+ lint_roller (~> 1.1.0)
127
+ parallel (>= 1.10)
128
+ parser (>= 3.3.0.2)
117
129
  rainbow (>= 2.2.2, < 4.0)
118
- regexp_parser (>= 1.8, < 3.0)
119
- rexml (>= 3.2.5, < 4.0)
120
- rubocop-ast (>= 1.30.0, < 2.0)
130
+ regexp_parser (>= 2.9.3, < 3.0)
131
+ rubocop-ast (>= 1.49.0, < 2.0)
121
132
  ruby-progressbar (~> 1.7)
122
- unicode-display_width (>= 2.4.0, < 3.0)
123
- rubocop-ast (1.30.0)
124
- parser (>= 3.2.1.0)
133
+ unicode-display_width (>= 2.4.0, < 4.0)
134
+ rubocop-ast (1.51.0)
135
+ parser (>= 3.3.7.2)
136
+ prism (>= 1.7)
137
+ rubocop-performance (1.26.1)
138
+ lint_roller (~> 1.1)
139
+ rubocop (>= 1.75.0, < 2.0)
140
+ rubocop-ast (>= 1.47.1, < 2.0)
125
141
  ruby-progressbar (1.13.0)
126
- ruby2_keywords (0.0.5)
142
+ securerandom (0.4.1)
127
143
  shellany (0.0.1)
128
- sqlite3 (1.4.2)
129
- strscan (3.1.0)
130
- terminal-notifier (2.0.0)
131
- thor (1.3.0)
132
- timeout (0.4.1)
144
+ sqlite3 (2.10.2)
145
+ mini_portile2 (~> 2.8.0)
146
+ sqlite3 (2.10.2-x86_64-linux-gnu)
147
+ standard (1.57.0)
148
+ language_server-protocol (~> 3.17.0.2)
149
+ lint_roller (~> 1.0)
150
+ rubocop (~> 1.91.0)
151
+ standard-custom (~> 1.0.0)
152
+ standard-performance (~> 1.8)
153
+ standard-custom (1.0.2)
154
+ lint_roller (~> 1.0)
155
+ rubocop (~> 1.50)
156
+ standard-performance (1.9.0)
157
+ lint_roller (~> 1.1)
158
+ rubocop-performance (~> 1.26.0)
159
+ thor (1.5.0)
160
+ timeout (0.6.1)
133
161
  tzinfo (2.0.6)
134
162
  concurrent-ruby (~> 1.0)
135
- unicode-display_width (2.5.0)
163
+ unicode-display_width (3.3.0)
164
+ unicode-emoji (~> 4.3)
165
+ unicode-emoji (4.3.0)
166
+ uri (1.1.2)
136
167
 
137
168
  PLATFORMS
138
169
  ruby
170
+ x86_64-linux
139
171
 
140
172
  DEPENDENCIES
141
173
  appraisal
142
174
  auto_increment!
143
- bundler
144
175
  database_cleaner
145
176
  fuubar
146
177
  guard
147
178
  guard-rspec
148
179
  rake
149
180
  rspec
150
- rspec-nc
151
- rubocop
152
- sqlite3 (>= 1.3.13)
181
+ sqlite3 (~> 2.10.2)
182
+ standard
153
183
 
154
184
  BUNDLED WITH
155
185
  2.4.22
data/Guardfile CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- guard :rspec, cmd: 'bundle exec rspec' do
3
+ guard :rspec, cmd: "bundle exec rspec" do
4
4
  watch(%r{^spec/.+_spec\.rb$})
5
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
6
- watch('spec/spec_helper.rb') { 'spec' }
5
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
6
+ watch("spec/spec_helper.rb") { "spec" }
7
7
  end