Skip to content

Support Rails 8.1 for the SQLite3 adapter - #1225

Merged
headius merged 1 commit into
jruby:masterfrom
k0kubun:rails-8.1-sqlite3-compat
Sep 29, 2026
Merged

headius merged 1 commit into
jruby:masterfrom
k0kubun:rails-8.1-sqlite3-compat

Conversation

@k0kubun

@k0kubun k0kubun commented Aug 31, 2026

Copy link
Copy Markdown

This patch fixes bundle exec rake test_sqlite3 with ActiveRecord 8.1. I tested this driver with ruby/ruby-bench as well, which currently uses Rails 8.1 and SQLite3.

Please see the commit message for the details of each change.

* 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.
@headius

headius commented Sep 29, 2026

Copy link
Copy Markdown
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 headius left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to merge these and fix the 8.0-isms in place.

@headius
headius merged commit 61ba994 into jruby:master Sep 29, 2026
4 of 13 checks passed
@k0kubun
k0kubun deleted the rails-8.1-sqlite3-compat branch September 29, 2026 18:23
@k0kubun
k0kubun restored the rails-8.1-sqlite3-compat branch September 29, 2026 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants