rails-uuid-pk 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/README.md +1 -1
- data/lib/rails_uuid_pk/mysql2_adapter_extension.rb +15 -0
- data/lib/rails_uuid_pk/railtie.rb +24 -17
- data/lib/rails_uuid_pk/sqlite3_adapter_extension.rb +16 -0
- data/lib/rails_uuid_pk/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cda21a747f154d1863e741ecce9b44855009bc202b11524be1a48911c6945ee2
|
|
4
|
+
data.tar.gz: f513b130b54f7d2230a13aa53bd60b707174005eff1bb792c0380a9d2b80a885
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 44070a3cf56eca32a1e83abdb83fa084abcb8c6042d2a2e06f3314bcfbf9df4e12a2794a5fab1e7d50d589455f2242dbf7e141618cd2b2b721b76be92ddfdc0f
|
|
7
|
+
data.tar.gz: 04ca3df41f44ca36bba89849a5c2a515481417b28b995670ecb93fb7a87a90abe5d9bf74bdb1b3a31c109a28127df2b9478bd63adbfa83fb5d0011e0b334a872
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v1.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.8.0] - 2026-01-12
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- **Refactored UUID Type Registration**: Moved from global type map registration to connection-specific registration for improved precision and database compatibility
|
|
12
|
+
- **Enhanced Type Mapping Precision**: UUID types now only map to specific `varchar(36)` and `uuid` SQL types, preventing hijacking of standard string columns
|
|
13
|
+
- **Improved Adapter Extensions**: Enhanced MySQL and SQLite adapter extensions with dedicated `register_uuid_types` methods and proper initialization hooks
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
- **String Column Protection Test**: Added test to ensure standard string columns are not incorrectly mapped to UUID type
|
|
17
|
+
|
|
18
|
+
### Technical Details
|
|
19
|
+
- Updated Railtie to use `ActiveSupport.on_load` hooks for cleaner adapter extension prepending
|
|
20
|
+
- Implemented connection-aware UUID type registration during adapter initialization and connection setup
|
|
21
|
+
- Enhanced migration helpers compatibility and type detection robustness
|
|
22
|
+
|
|
8
23
|
## [0.7.0] - 2026-01-12
|
|
9
24
|
|
|
10
25
|
### Added
|
data/README.md
CHANGED
|
@@ -5,5 +5,20 @@ module RailsUuidPk
|
|
|
5
5
|
uuid: { name: "varchar", limit: 36 }
|
|
6
6
|
)
|
|
7
7
|
end
|
|
8
|
+
|
|
9
|
+
def register_uuid_types(m = type_map)
|
|
10
|
+
m.register_type(/varchar\(36\)/i) { RailsUuidPk::Type::Uuid.new }
|
|
11
|
+
m.register_type("uuid") { RailsUuidPk::Type::Uuid.new }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def initialize_type_map(m = type_map)
|
|
15
|
+
super
|
|
16
|
+
register_uuid_types(m)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def configure_connection
|
|
20
|
+
super
|
|
21
|
+
register_uuid_types
|
|
22
|
+
end
|
|
8
23
|
end
|
|
9
24
|
end
|
|
@@ -16,17 +16,31 @@ module RailsUuidPk
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
initializer "rails-uuid-pk.native_types" do
|
|
19
|
+
ActiveSupport.on_load(:active_record_sqlite3adapter) do
|
|
20
|
+
prepend RailsUuidPk::Sqlite3AdapterExtension
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
ActiveSupport.on_load(:active_record_mysql2adapter) do
|
|
24
|
+
prepend RailsUuidPk::Mysql2AdapterExtension
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
config.after_initialize do
|
|
19
29
|
ActiveSupport.on_load(:active_record) do
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
if ActiveRecord::Base.connected?
|
|
31
|
+
ActiveRecord::Base.connection_handler.connection_pool_list.each do |pool|
|
|
32
|
+
connections = if pool.respond_to?(:connections)
|
|
33
|
+
pool.connections
|
|
34
|
+
else
|
|
35
|
+
# Fallback or older rails
|
|
36
|
+
[ pool.connection ] rescue []
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
connections.each do |conn|
|
|
40
|
+
if conn.respond_to?(:register_uuid_types)
|
|
41
|
+
conn.register_uuid_types
|
|
42
|
+
end
|
|
43
|
+
end
|
|
30
44
|
end
|
|
31
45
|
end
|
|
32
46
|
end
|
|
@@ -54,13 +68,6 @@ module RailsUuidPk
|
|
|
54
68
|
|
|
55
69
|
def self.register_uuid_type(adapter)
|
|
56
70
|
ActiveRecord::Type.register(:uuid, RailsUuidPk::Type::Uuid, adapter: adapter)
|
|
57
|
-
|
|
58
|
-
# Get the connection-specific type map
|
|
59
|
-
type_map = ActiveRecord::Base.connection.send(:type_map)
|
|
60
|
-
# Map varchar(36) or varchar SQL type to our custom UUID type
|
|
61
|
-
type_map.register_type(/varchar/i) { RailsUuidPk::Type::Uuid.new }
|
|
62
|
-
# Also map "uuid" SQL type for direct lookups
|
|
63
|
-
type_map.register_type("uuid") { RailsUuidPk::Type::Uuid.new }
|
|
64
71
|
end
|
|
65
72
|
end
|
|
66
73
|
end
|
|
@@ -5,5 +5,21 @@ module RailsUuidPk
|
|
|
5
5
|
uuid: { name: "varchar", limit: 36 }
|
|
6
6
|
)
|
|
7
7
|
end
|
|
8
|
+
|
|
9
|
+
def register_uuid_types(m = type_map)
|
|
10
|
+
puts "[RailsUuidPk] Registering UUID types on #{m.class}"
|
|
11
|
+
m.register_type(/varchar\(36\)/i) { RailsUuidPk::Type::Uuid.new }
|
|
12
|
+
m.register_type("uuid") { RailsUuidPk::Type::Uuid.new }
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def initialize_type_map(m = type_map)
|
|
16
|
+
super
|
|
17
|
+
register_uuid_types(m)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def configure_connection
|
|
21
|
+
super
|
|
22
|
+
register_uuid_types
|
|
23
|
+
end
|
|
8
24
|
end
|
|
9
25
|
end
|