File tree Expand file tree Collapse file tree 3 files changed +38
-36
lines changed
lib/sqlite_extensions/uuid Expand file tree Collapse file tree 3 files changed +38
-36
lines changed Original file line number Diff line number Diff line change 1
- # frozen_string_literal: true
2
-
3
- require "sqlite_extensions/uuid"
4
-
5
- module SqliteExtensions
6
- module UUID
7
- class Railtie < Rails ::Railtie
8
- initializer "sqlite_extensions-uuid.patch_database_adapter" do
9
- ActiveSupport . on_load ( :active_record_sqlite3adapter ) do
10
- prepend DatabaseAdapterExtension
11
- end
12
- end
13
-
14
- module DatabaseAdapterExtension
15
- # https://github.com/rails/rails/blob/v8.0.0.rc1/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb#L815
16
- def configure_connection
17
- super
18
-
19
- begin
20
- @raw_connection . enable_load_extension ( true )
21
- @raw_connection . load_extension ( SqliteExtensions ::UUID . extension_path )
22
- rescue SQLite3 ::Exception => e
23
- # no such function: uuid (SQLite3::SQLException)
24
- Rails . logger . error do
25
- "Error loading sqlite extension '#{ SqliteExtensions ::UUID . extension_path } ' (#{ e } )"
26
- end
27
- ensure
28
- @raw_connection . enable_load_extension ( false )
29
- end
30
- end
31
- end
32
-
33
- private_constant :DatabaseAdapterExtension
34
- end
35
- end
36
- end
1
+ require_relative "railtie"
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ require "sqlite_extensions/uuid"
4
+
5
+ module SqliteExtensions
6
+ module UUID
7
+ class Railtie < Rails ::Railtie
8
+ initializer "sqlite_extensions-uuid.patch_database_adapter" do
9
+ ActiveSupport . on_load ( :active_record_sqlite3adapter ) do
10
+ prepend DatabaseAdapterExtension
11
+ end
12
+ end
13
+
14
+ module DatabaseAdapterExtension
15
+ # https://github.com/rails/rails/blob/v8.0.0.rc1/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb#L815
16
+ def configure_connection
17
+ super
18
+
19
+ begin
20
+ @raw_connection . enable_load_extension ( true )
21
+ @raw_connection . load_extension ( SqliteExtensions ::UUID . extension_path )
22
+ rescue SQLite3 ::Exception => e
23
+ # no such function: uuid (SQLite3::SQLException)
24
+ Rails . logger . error do
25
+ "Error loading sqlite extension '#{ SqliteExtensions ::UUID . extension_path } ' (#{ e } )"
26
+ end
27
+ ensure
28
+ @raw_connection . enable_load_extension ( false )
29
+ end
30
+ end
31
+ end
32
+
33
+ private_constant :DatabaseAdapterExtension
34
+ end
35
+ end
36
+ end
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ Gem::Specification.new do |spec|
16
16
spec . files = %w[
17
17
lib/sqlite_extensions/uuid.rb
18
18
lib/sqlite_extensions/uuid/rails.rb
19
+ lib/sqlite_extensions/uuid/railtie.rb
19
20
ext/sqlite_extensions/uuid/sqlite3ext.h
20
21
ext/sqlite_extensions/uuid/sqlite3.h
21
22
ext/sqlite_extensions/uuid/uuid.c
You can’t perform that action at this time.
0 commit comments