Support loading SQLite3 extensions with config/database.yml#53827
Merged
eileencodes merged 1 commit intorails:mainfrom Dec 4, 2024
Merged
Conversation
Member
Author
|
The CI failure seems like an unrelated flake. |
eileencodes
requested changes
Dec 4, 2024
Member
eileencodes
left a comment
There was a problem hiding this comment.
Thanks! One comment on docs, but otherwise this looks good.
The `sqlite3` gem v2.4.0 introduces support for loading extensions that are passed to the Database constructor. This feature leverages that feature to allow configuration of extensions using either filesystem paths or the names of modules that respond to `.to_path`. This commit documents the feature in both SQLite3Adapter rdoc and the "Configuring" guide. It also extends and improves the documentation around general SQLite3Adapter configuration. See sparklemotion/sqlite3-ruby#586 for more information.
36613fe to
b599d4c
Compare
Member
Author
|
@eileencodes Thanks! I just force-pushed an amended commit addressing the docs comment. |
tenderlove
approved these changes
Dec 4, 2024
eileencodes
approved these changes
Dec 4, 2024
rossta
added a commit
to rossta/asg017-sqlite-dist
that referenced
this pull request
Dec 12, 2024
The sqlite3-ruby recently published an improvement to make it easier and more flexible to load extensions: sparklemotion/sqlite3-ruby#586 Ruby modules for SQLite extensions should implement the interface: interface _ExtensionSpecifier def to_path: () → String end A complementary change in Rails takes advantage of this interface to integrate the primary configuration file with the new sqlite3-ruby interface for extension loading: rails/rails#53827 The gem template provided here already has a similar method: def loadable_path The change proposed here is to modify the gem template to provide an alias to loadable_path as to_path.o # example SqliteVec.to_path # => returns same result as loadable_path As a result of this change, Ruby gems published with this tool will conform to the new interface supported in sqlite3-ruby and Rails.
rossta
added a commit
to rossta/asg017-sqlite-dist
that referenced
this pull request
Dec 12, 2024
The sqlite3-ruby recently published an improvement to make it easier and more flexible to load extensions: sparklemotion/sqlite3-ruby#586 Ruby modules for SQLite extensions should implement the interface: interface _ExtensionSpecifier def to_path: () → String end A complementary change in Rails takes advantage of this interface to integrate the primary configuration file with the new sqlite3-ruby interface for extension loading: rails/rails#53827 The gem template provided here already has a similar method: def loadable_path The change proposed here is to modify the gem template to provide an alias to loadable_path as to_path.o # example SqliteVec.to_path # => returns same result as loadable_path As a result of this change, Ruby gems published with this tool will conform to the new interface supported in sqlite3-ruby and Rails.
This was referenced Dec 12, 2024
thibaudgg
added a commit
to csa-admin-org/csa-admin
that referenced
this pull request
Mar 4, 2025
This patch aims to improve string ordering by properly support accent character. SQLite extensions are required, which is supported on Rails main branch. rails/rails#53827 https://fractaledmind.github.io/2024/12/09/sqlite-on-rails-loading-extensions/
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.
Motivation / Background
The
sqlite3gem v2.4.0 introduces support for loading extensions passed as a kwarg toDatabase.new. This PR leverages that feature to allow configuration of extensions in thedatabase.ymlfile using either filesystem paths or the names of modules that respond to.to_path.Documentation is added to both SQLite3Adapter rdoc and the "Configuring" guide. It also extends and improves the documentation around general SQLite3Adapter configuration.
See sparklemotion/sqlite3-ruby#586 for more information.
Detail
The SQLite3Adapter is designed to pass the database config to the SQLite3::Database constructor, so configuring
extensionswith filesystem paths will work without this PR like this:What this PR does, though, is allow this usage:
which I think is more readable and ergonomic.
Additional information
See sparklemotion/sqlite3-ruby#586 for how the underlying driver changed in v2.4.0.
For an idea of what using extensions looked like until now, check out this blog post from @fractaledmind which talks about using this Rails initializer to inject extensions.
Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]