active_record-cursor_paginator 0.3.0 → 0.3.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: 19564a0a0f62ea77cf5876fc9d125f27474aba8fec598a6a84e6b215b13edb22
4
- data.tar.gz: e9856e7730229847a6d345c7b2cab49062b2351216fb02a775c1a4d3d8c19ca6
3
+ metadata.gz: 0e6079364fab39f26c9d63199730cc44ae0138c5c3d8452aa1b73219e0afa0e1
4
+ data.tar.gz: 36d9c3020d18dafe2905b18a6a50bebee06ab17caff4ff4abd4eb9bb965aa851
5
5
  SHA512:
6
- metadata.gz: c899b2ea56ffd2a65edabbbd06421bc695263555488b8068cf0c753d4cf84e6ca1c57837b339ed7237d47ab8d200c6242d52ded55ffc991c3df784a0c0056ec6
7
- data.tar.gz: 3f037675aa41403536d136e99faa7c08ec0184c5756fd91cabb88e6d72bdbec3f2be3cc1cbe83ab8efa2538218d35121e05c8c312e0683c26332ad16cbb8bc8c
6
+ metadata.gz: db459de8e2b52873f5ccb95e9bb7b957af9381a30fcfca97786189874bfacc8808f80fb939ea86d54c8f50cb5983b263089df16f4e7f2294387d41757cf723d1
7
+ data.tar.gz: a344ab46f80d38a5c43d890793031a31194d3f3b7dfe6b53258c94a77a08386470c7201e46f5d6833cd2f9e77c0f3fa940afb0306c951648193b1f04f0530ce9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.3.1] - 2026-03-06
2
+
3
+ - Add support for Rails enum columns
4
+
1
5
  ## [0.3.0] - 2025-12-10
2
6
 
3
7
  - Fix ambiguous column error
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveRecord
4
4
  class CursorPaginator
5
- VERSION = '0.3.0'
5
+ VERSION = '0.3.1'
6
6
  end
7
7
  end
@@ -160,10 +160,23 @@ module ActiveRecord
160
160
  # value from this other field as well as the records ID to resolve the order
161
161
  # of duplicates in the non-ID field.
162
162
  #
163
+ # For enum columns, we store the raw integer value instead of the string
164
+ # representation to ensure proper SQL comparison in WHERE clauses.
165
+ #
163
166
  # @param record [ActiveRecord] Model instance for which we want the cursor
164
167
  # @return [String]
165
168
  def cursor_for_record(record)
166
- unencoded_cursor = @fields.map {|field| { field.keys.first => record[field.keys.first] } }
169
+ unencoded_cursor = @fields.map do |field|
170
+ field_name = field.keys.first
171
+ value = if record.class.defined_enums.key?(field_name.to_s)
172
+ # For enum columns, get the raw integer value from the database
173
+ record.read_attribute_before_type_cast(field_name)
174
+ else
175
+ # For regular columns, get the typed value
176
+ record[field_name]
177
+ end
178
+ { field_name => value }
179
+ end
167
180
  Base64.strict_encode64(unencoded_cursor.to_json)
168
181
  end
169
182
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record-cursor_paginator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shinichi Sugiyama
@@ -42,7 +42,6 @@ files:
42
42
  - Gemfile
43
43
  - README.md
44
44
  - Rakefile
45
- - active_record-cursor_paginator.gemspec
46
45
  - lib/active_record/cursor_paginator.rb
47
46
  - lib/active_record/cursor_paginator/version.rb
48
47
  homepage: https://github.com/ssugiyama/active_record-cursor_paginator
@@ -67,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
66
  - !ruby/object:Gem::Version
68
67
  version: '0'
69
68
  requirements: []
70
- rubygems_version: 3.6.7
69
+ rubygems_version: 3.7.2
71
70
  specification_version: 4
72
71
  summary: cursor pagination for ActiveRecord
73
72
  test_files: []
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'lib/active_record/cursor_paginator/version'
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = 'active_record-cursor_paginator'
7
- spec.version = ActiveRecord::CursorPaginator::VERSION
8
- spec.authors = ['Shinichi Sugiyama']
9
- spec.email = ['sugiyama-shinichi@kayac.com']
10
-
11
- spec.summary = 'cursor pagination for ActiveRecord'
12
- spec.description =
13
- 'This library is an implementation of cursor pagination for ActiveRecord relations ' \
14
- 'based on "https://github.com/xing/rails_cursor_pagination". ' \
15
- 'Additional features are: ' \
16
- '- receives a relation with orders, and it is unnecessary to specify orders to this library separately.' \
17
- '- supports bidirectional pagination.'
18
-
19
- spec.homepage = 'https://github.com/ssugiyama/active_record-cursor_paginator'
20
- spec.license = 'MIT'
21
- spec.required_ruby_version = Gem::Requirement.new('>= 3.0.0')
22
-
23
- spec.metadata['homepage_uri'] = spec.homepage
24
- spec.metadata['source_code_uri'] = spec.homepage
25
- spec.metadata['changelog_uri'] = "#{spec.homepage}/Changelog.md"
26
-
27
- # Specify which files should be added to the gem when it is released.
28
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
29
- spec.files = Dir.chdir(__dir__) do
30
- `git ls-files -z`.split("\x0").reject do |f|
31
- (File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor])
32
- end
33
- end
34
- spec.bindir = 'exe'
35
- spec.executables = spec.files.grep(%r{\Aexe/}) {|f| File.basename(f) }
36
- spec.require_paths = ['lib']
37
-
38
- # Uncomment to register a new dependency of your gem
39
- # spec.add_dependency "example-gem", "~> 1.0"
40
- spec.add_dependency 'activerecord', '>= 6.0'
41
-
42
- # For more information and examples about making a new gem, check out our
43
- # guide at: https://bundler.io/guides/creating_gem.html
44
- spec.metadata['rubygems_mfa_required'] = 'true'
45
- end