Repository navigation
Support Rails 8.1 for the SQLite3 adapter - #1225
Merged
Merged
Conversation
* The `mark_transaction_written_if_write` / `check_if_write_query` shims were guarded with a bare `method_defined?`. That is evaluated against ArJdbc::Abstract::DatabaseStatements, which never defines those methods, so the guard was always true and the shims replaced the Rails 8.0 implementations with calls to `ensure_writes_are_allowed`, which only exists from 8.1 on. Ask AbstractAdapter instead. This is what broke 8.0. * Rails 8.1 inserted a `cast_type` positional argument into `Column#initialize`, so `new_column_from_field` was passing `default_value` as the cast type and Rails raised `undefined method 'mutable?' for nil`. * With a `cast_type` in hand Rails now deserializes the default, so SQLite3Column#initialize can no longer assume it is a String - a decimal column hands back a BigDecimal and `default =~ /NULL/` raised NoMethodError. * `lookup_cast_type_from_column` was removed in 8.1 in favour of `Column#fetch_cast_type`, which `copy_table` needs when rebuilding a table that has column defaults. * `AbstractAdapter#native_database_types` now delegates to `self.class.native_database_types`, so the schema dumper needs a class-level definition; without it every table dumped as "Could not dump table ... because of following NameError". The PostgreSQL adapter already defines both; do the same for SQLite3.
Member
|
Thank you for the patch! I started to review this, but realized that much of these changes would go away with our policy of only supporting one Rails level at a time. I have pushed an 80-stable branch that will go forward with the Rails 8.0 changes. At least one of the changes patched here came in from #1207, and the pre1 gems were known to be working, so I based the branch on the previous commit and cherry-picked the other benign changes from master. @k0kubun Please restructure this patch as though only 8.1 needs to be supported (most of the conditional logic should disappear). |
headius
approved these changes
Sep 29, 2026
headius
left a comment
Member
There was a problem hiding this comment.
I'm going to merge these and fix the 8.0-isms in place.
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.
This patch fixes
bundle exec rake test_sqlite3with ActiveRecord 8.1. I tested this driver withruby/ruby-benchas well, which currently uses Rails 8.1 and SQLite3.Please see the commit message for the details of each change.