typed_uuid 2.0 → 2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c9f8cc6a9d2e7768a94386004a4e36062d225eccb9671525d338e7e1b49b5a58
4
- data.tar.gz: 383fad6086cdd955c79a85efe0f408b27d1b4ed4fa8c586bda2ec02c501ac2ce
3
+ metadata.gz: d0743664e3f9987059821b25c8c42f80b062bbeeb3ba563e795d4b9845920505
4
+ data.tar.gz: ec150decbaced84ca8cbd26b06af761551969ee9cc74145291c552215ab2a94b
5
5
  SHA512:
6
- metadata.gz: 1442e2de994415398ba67ad9ba28ae491985d297303d8351d4472cf6a0bfa17e687ede6e15b0152066843cbcf987f86f569bdeaca29c09abc9744e14d49ea6fc
7
- data.tar.gz: f923a8e624f697f0043edd593a0fde9801744769f849a52e8d6f443f96b70e143d2ac208482c18347fcfab403afe41d8c0301ad71db73fc2a765810bb499e1e2
6
+ metadata.gz: e3e66ca9962d22a9ccece4458708c132e776062dc5d10071b715816c4c5329a99c6bea6b172e0f33a55c274a761e0850c1cb4a957b31de2124f3942d60204aa3
7
+ data.tar.gz: 502b8f036034be6a080aa0722b26918810589fc741666d2ab4f0c125d987895bc2ba19ab886b79ff13b97e38b50698808dbc28eb80d2b1d822c1dda055f89ad3
@@ -1,6 +1,7 @@
1
1
  module TypedUUID
2
2
  autoload :ActiveRecord, 'typed_uuid/active_record'
3
3
  autoload :PsqlColumnMethods, 'typed_uuid/psql_column_methods'
4
+ autoload :PsqlSchemaDumper, 'typed_uuid/psql_schema_dumper'
4
5
  end
5
6
 
6
7
  require 'typed_uuid/railtie' if defined? Rails
@@ -0,0 +1,25 @@
1
+ module TypedUUID::PsqlSchemaDumper
2
+
3
+ def extensions(stream)
4
+ super(stream)
5
+ stream.puts <<-RB
6
+ ## These are functions that must be enabled in order to support typed_uuids
7
+ ## in this database
8
+ execute <<-SQL
9
+ CREATE OR REPLACE FUNCTION typed_uuid(t bytea) RETURNS uuid AS $$
10
+ DECLARE
11
+ bytes bytea := gen_random_bytes(16);
12
+ uuid bytea;
13
+ BEGIN
14
+ bytes := set_byte(bytes, 6, (get_byte(bytes, 4) # get_byte(bytes, 8)) # get_byte(t, 0));
15
+ bytes := set_byte(bytes, 7, (get_byte(bytes, 5) # get_byte(bytes, 9)) # get_byte(t, 1));
16
+ RETURN encode( bytes, 'hex') :: uuid;
17
+ END;
18
+ $$ LANGUAGE plpgsql;
19
+ SQL
20
+
21
+ RB
22
+ stream
23
+ end
24
+
25
+ end
@@ -8,7 +8,9 @@ class TypedUUID::Railtie < Rails::Railtie
8
8
  end
9
9
 
10
10
  require 'active_record/connection_adapters/postgresql/schema_definitions'
11
- ActiveRecord::ConnectionAdapters::PostgreSQL::TableDefinition.include TypedUUID::PsqlColumnMethods
11
+ ActiveRecord::ConnectionAdapters::PostgreSQL::TableDefinition.include(TypedUUID::PsqlColumnMethods)
12
+
13
+ ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaDumper.prepend(TypedUUID::PsqlSchemaDumper)
12
14
  end
13
15
 
14
16
  end
@@ -1,3 +1,3 @@
1
1
  module TypedUUID
2
- VERSION = '2.0'
2
+ VERSION = '2.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typed_uuid
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.0'
4
+ version: '2.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Bracy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-23 00:00:00.000000000 Z
11
+ date: 2019-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -181,6 +181,7 @@ files:
181
181
  - lib/typed_uuid.rb
182
182
  - lib/typed_uuid/active_record.rb
183
183
  - lib/typed_uuid/psql_column_methods.rb
184
+ - lib/typed_uuid/psql_schema_dumper.rb
184
185
  - lib/typed_uuid/railtie.rb
185
186
  - lib/typed_uuid/version.rb
186
187
  - test/test_helper.rb