Skip to content

Commit

Permalink
tiny updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jethrodaniel committed Oct 21, 2024
1 parent 4a4dd88 commit a89ff17
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ It then exposes a method (`SqliteExtensions::UUID.extension_path`) which returns

For Rails, it also exposes a [railtie](https://api.rubyonrails.org/v7.2/classes/Rails/Railtie.html) (via `require: "sqlite_extensions/uuid/rails"`) that patches Rails' [configure_connection](https://github.com/rails/rails/blob/v8.0.0.rc1/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb#L815) method for the SQLite adapter, so that all SQLite database connections load the extension.

Ideally, Rails will eventually provide an official way to configure the SQLite connection, at which point we can migrate the railtie to that approach.
This doesn't scale well to supporting multiple SQLite extensions, but works fine if all you need is the UUID extension.

Ideally, Rails will eventually provide an official way to configure the SQLite connection, at which point we can migrate the railtie to that approach.

## Development

Expand Down
2 changes: 2 additions & 0 deletions lib/sqlite_extensions/uuid/rails.rb
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# frozen_string_literal: true

require_relative "railtie"
5 changes: 1 addition & 4 deletions lib/sqlite_extensions/uuid/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ def configure_connection
@raw_connection.enable_load_extension(true)
@raw_connection.load_extension(SqliteExtensions::UUID.extension_path)
rescue SQLite3::Exception => e
# no such function: uuid (SQLite3::SQLException)
Rails.logger.error do
"Error loading sqlite extension '#{SqliteExtensions::UUID.extension_path}' (#{e})"
end
Rails.logger.error { "Error loading sqlite extension '#{SqliteExtensions::UUID.extension_path}' (#{e})" }
ensure
@raw_connection.enable_load_extension(false)
end
Expand Down

0 comments on commit a89ff17

Please sign in to comment.