Serialize :date column type in cursor to ISO8601 string format#652
Merged
Conversation
- Enhanced `column_value` method to serialize `Date` objects as ISO8601 strings. - Added handling for `:date` column type in `active_record_enumerator`. - Introduced new tests covering serialization of `Date` values and cursor resumption. - Updated test setup to include `Event` model and its related schema.
Mangara
approved these changes
Dec 2, 2025
Mangara
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the contribution, it looks good! Can you add a change log entry under "unreleased"?
- Added entry referencing PR Shopify#652 that resolves ISO8601 serialization issue for `Date` columns in ActiveRecord enumerators.
Contributor
Author
Done, added information about this to the changelog. |
Contributor
Author
|
@Mangara Hi. Anything else needed for CI and PR merge? |
Mangara
approved these changes
Dec 4, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When using
job-iterationwith ActiveRecord models that have a:datecolumn in their primary key or as a cursor column, the cursor value is not serialized to a string. This causes issues when:strict_args!mode enabled (recommended best practice).maintenance_tasksgem which relies onjob-iterationinternally.The error message users see:
Root Cause
The
column_valuemethod in bothActiveRecordEnumeratorandActiveRecordBatchEnumeratorhandles:datetimetype columns by converting them to strings, but does not handle:datetype columns:ActiveRecordEnumerator (checks column type):
ActiveRecordBatchEnumerator (checks value class):
Solution
Add
:datetype handling in both enumerators, serializing Date values to ISO8601 format ("2025-10-03"):ActiveRecordEnumerator#column_value: Added when:datecase.ActiveRecordBatchEnumerator#column_value: Added whenDatecase.The ISO8601 format was chosen because:
Testing
Added tests that verify:
Backward Compatibility
This change is fully backward compatible. Existing cursors with datetime columns continue to work as before. New cursors with date columns will now work correctly.