ar-uuid 0.1.2 → 0.2.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/.travis.yml +16 -4
- data/Gemfile +1 -3
- data/LICENSE.txt +21 -0
- data/README.md +15 -3
- data/Rakefile +7 -3
- data/ar-uuid.gemspec +17 -15
- data/gemfiles/4_2.gemfile +3 -0
- data/gemfiles/4_2.gemfile.lock +81 -0
- data/gemfiles/5_0.gemfile +3 -0
- data/gemfiles/5_0.gemfile.lock +80 -0
- data/gemfiles/5_1.gemfile +3 -0
- data/gemfiles/5_1.gemfile.lock +80 -0
- data/lib/active_record/uuid.rb +7 -6
- data/lib/active_record/uuid/ext.rb +1 -1
- data/lib/active_record/uuid/table_definition.rb +6 -0
- data/lib/active_record/uuid/utils.rb +45 -0
- data/lib/active_record/uuid/version.rb +1 -1
- data/lib/ar-uuid.rb +1 -1
- metadata +53 -17
- data/.rspec +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 335852436c46e3b7e54a96159f2a9d917418395d
|
4
|
+
data.tar.gz: 01ca25d3c78af83d0a92309f9b7ac709ba524bfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 032d498919aaf76791ab41881cd99f55bf352649ca9136d1a9250ef72f52d05c8b5071f50e891527f0b596626efa4e9c7f8078444eaddf34740611856962a1eb
|
7
|
+
data.tar.gz: 3f2fa600d1cc5d4f977d7d6f54e875eea5c48d76529a7e3955a4c2dcf88ebaf5b6ee60827ac325dcf875576ab385f3731c6e5956a0a727ca6df39a665d6571ec
|
data/.travis.yml
CHANGED
@@ -2,9 +2,21 @@ language: ruby
|
|
2
2
|
sudo: false
|
3
3
|
cache: bundler
|
4
4
|
before_install:
|
5
|
-
|
5
|
+
- gem install bundler
|
6
6
|
before_script:
|
7
|
-
|
7
|
+
- createdb test
|
8
|
+
addons:
|
9
|
+
postgresql: "9.4"
|
8
10
|
rvm:
|
9
|
-
|
10
|
-
|
11
|
+
- 2.4.1
|
12
|
+
gemfile:
|
13
|
+
- gemfiles/5_1.gemfile
|
14
|
+
- gemfiles/5_0.gemfile
|
15
|
+
- gemfiles/4_2.gemfile
|
16
|
+
env:
|
17
|
+
global:
|
18
|
+
secure: jx2vy7MRmkFfs2DUx4+Yh7sxMw8yYlPyZuGt4f3S1Myb3voOrsht/9mJ5QENhKX/Rx+u5BBHCPS/YgKZKb12xYCQZwH3NLTk0etQZCykFfgtOmKYEJmIro/61Ctqdz/lo9LUQ3PRxs0bfvlOeygGTc6+XmK2KpyYF1RSIPJ+A2s=
|
19
|
+
notifications:
|
20
|
+
email: false
|
21
|
+
after_success:
|
22
|
+
- bundle exec codeclimate-test-reporter
|
data/Gemfile
CHANGED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Nando Vieira
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# ActiveRecord::UUID
|
2
2
|
|
3
|
-
[](https://travis-ci.org/fnando/ar-uuid)
|
4
|
+
[](https://codeclimate.com/github/fnando/ar-uuid)
|
5
|
+
[](https://codeclimate.com/github/fnando/ar-uuid/coverage)
|
6
|
+
[](https://rubygems.org/gems/ar-uuid)
|
7
|
+
[](https://rubygems.org/gems/ar-uuid)
|
4
8
|
|
5
9
|
Override migration methods to support UUID columns without having to be explicit about it.
|
6
10
|
|
@@ -14,7 +18,7 @@ What this gem will do for you:
|
|
14
18
|
Add this line to your application's Gemfile:
|
15
19
|
|
16
20
|
```ruby
|
17
|
-
gem
|
21
|
+
gem "ar-uuid"
|
18
22
|
```
|
19
23
|
|
20
24
|
And then execute:
|
@@ -48,6 +52,14 @@ create_table :users do |t|
|
|
48
52
|
end
|
49
53
|
```
|
50
54
|
|
55
|
+
### Disadvantages
|
56
|
+
|
57
|
+
There is one big disadvantage on using uuid identifiers: you can't use methods like `ActiveRecord::FinderMethods::InstanceMethods#first` and `ActiveRecord::FinderMethods::InstanceMethods#last`, since they are scoped to the sequential id.
|
58
|
+
|
59
|
+
Instead of `.first`, you can use [ActiveRecord::FinderMethods::InstanceMethods#take](https://github.com/rails/rails/blob/f52354ad1d15120dcc5284714bee7ee3f052986c/activerecord/lib/active_record/relation/finder_methods.rb#L104), which will use the order implemented by the database.
|
60
|
+
|
61
|
+
There's no alternative to `.last`.
|
62
|
+
|
51
63
|
## Development
|
52
64
|
|
53
65
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -56,7 +68,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
56
68
|
|
57
69
|
## Contributing
|
58
70
|
|
59
|
-
1. Fork it ( https://github.com/
|
71
|
+
1. Fork it ( https://github.com/fnando/ar-uuid/fork )
|
60
72
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
61
73
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
62
74
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/Rakefile
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
-
require "
|
2
|
+
require "rake/testtask"
|
3
3
|
|
4
|
-
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
5
|
+
t.libs << "test"
|
6
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
7
|
+
t.warning = false
|
8
|
+
end
|
5
9
|
|
6
|
-
task :
|
10
|
+
task default: :test
|
data/ar-uuid.gemspec
CHANGED
@@ -1,24 +1,26 @@
|
|
1
|
-
require
|
1
|
+
require "./lib/active_record/uuid/version"
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
|
-
spec.
|
5
|
-
spec.name = 'ar-uuid'
|
4
|
+
spec.name = "ar-uuid"
|
6
5
|
spec.version = ActiveRecord::UUID::VERSION
|
7
|
-
spec.authors = [
|
8
|
-
spec.email = [
|
9
|
-
spec.summary = %[Add UUID support for ActiveRecord. It enforces uuid primary keys, fixes ActiveRecord
|
6
|
+
spec.authors = ["Nando Vieira"]
|
7
|
+
spec.email = ["fnando.vieira@gmail.com"]
|
8
|
+
spec.summary = %[Add UUID support for ActiveRecord. It enforces uuid primary keys, fixes ActiveRecord"s first/last methods and more.]
|
10
9
|
spec.description = spec.summary
|
11
|
-
spec.homepage =
|
10
|
+
spec.homepage = "http://rubygems.org/gems/ar-uuid"
|
11
|
+
spec.license = "MIT"
|
12
12
|
|
13
13
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
14
|
-
spec.bindir =
|
14
|
+
spec.bindir = "exe"
|
15
15
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
16
|
-
spec.require_paths = [
|
16
|
+
spec.require_paths = ["lib"]
|
17
17
|
|
18
|
-
spec.add_dependency
|
19
|
-
spec.add_development_dependency
|
20
|
-
spec.add_development_dependency
|
21
|
-
spec.add_development_dependency
|
22
|
-
spec.add_development_dependency
|
23
|
-
spec.add_development_dependency
|
18
|
+
spec.add_dependency "activerecord"
|
19
|
+
spec.add_development_dependency "bundler"
|
20
|
+
spec.add_development_dependency "rake"
|
21
|
+
spec.add_development_dependency "minitest-utils"
|
22
|
+
spec.add_development_dependency "mocha"
|
23
|
+
spec.add_development_dependency "pg"
|
24
|
+
spec.add_development_dependency "pry-meta"
|
25
|
+
spec.add_development_dependency "codeclimate-test-reporter"
|
24
26
|
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
ar-uuid (0.1.2)
|
5
|
+
activerecord
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activemodel (4.2.8)
|
11
|
+
activesupport (= 4.2.8)
|
12
|
+
builder (~> 3.1)
|
13
|
+
activerecord (4.2.8)
|
14
|
+
activemodel (= 4.2.8)
|
15
|
+
activesupport (= 4.2.8)
|
16
|
+
arel (~> 6.0)
|
17
|
+
activesupport (4.2.8)
|
18
|
+
i18n (~> 0.7)
|
19
|
+
minitest (~> 5.1)
|
20
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
21
|
+
tzinfo (~> 1.1)
|
22
|
+
arel (6.0.4)
|
23
|
+
awesome_print (1.8.0)
|
24
|
+
builder (3.2.3)
|
25
|
+
byebug (9.0.6)
|
26
|
+
codeclimate-test-reporter (1.0.8)
|
27
|
+
simplecov (<= 0.13)
|
28
|
+
coderay (1.1.1)
|
29
|
+
docile (1.1.5)
|
30
|
+
i18n (0.8.4)
|
31
|
+
json (2.1.0)
|
32
|
+
metaclass (0.0.4)
|
33
|
+
method_source (0.8.2)
|
34
|
+
minitest (5.10.2)
|
35
|
+
minitest-utils (0.3.1)
|
36
|
+
minitest
|
37
|
+
mocha (1.2.1)
|
38
|
+
metaclass (~> 0.0.1)
|
39
|
+
pg (0.21.0)
|
40
|
+
pry (0.10.4)
|
41
|
+
coderay (~> 1.1.0)
|
42
|
+
method_source (~> 0.8.1)
|
43
|
+
slop (~> 3.4)
|
44
|
+
pry-byebug (3.4.2)
|
45
|
+
byebug (~> 9.0)
|
46
|
+
pry (~> 0.10)
|
47
|
+
pry-meta (0.0.10)
|
48
|
+
awesome_print
|
49
|
+
pry
|
50
|
+
pry-byebug
|
51
|
+
pry-remote
|
52
|
+
pry-remote (0.1.8)
|
53
|
+
pry (~> 0.9)
|
54
|
+
slop (~> 3.0)
|
55
|
+
rake (12.0.0)
|
56
|
+
simplecov (0.13.0)
|
57
|
+
docile (~> 1.1.0)
|
58
|
+
json (>= 1.8, < 3)
|
59
|
+
simplecov-html (~> 0.10.0)
|
60
|
+
simplecov-html (0.10.1)
|
61
|
+
slop (3.6.0)
|
62
|
+
thread_safe (0.3.6)
|
63
|
+
tzinfo (1.2.3)
|
64
|
+
thread_safe (~> 0.1)
|
65
|
+
|
66
|
+
PLATFORMS
|
67
|
+
ruby
|
68
|
+
|
69
|
+
DEPENDENCIES
|
70
|
+
activerecord (~> 4.2.0)
|
71
|
+
ar-uuid!
|
72
|
+
bundler
|
73
|
+
codeclimate-test-reporter
|
74
|
+
minitest-utils
|
75
|
+
mocha
|
76
|
+
pg
|
77
|
+
pry-meta
|
78
|
+
rake
|
79
|
+
|
80
|
+
BUNDLED WITH
|
81
|
+
1.15.1
|
@@ -0,0 +1,80 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
ar-uuid (0.1.2)
|
5
|
+
activerecord
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activemodel (5.0.3)
|
11
|
+
activesupport (= 5.0.3)
|
12
|
+
activerecord (5.0.3)
|
13
|
+
activemodel (= 5.0.3)
|
14
|
+
activesupport (= 5.0.3)
|
15
|
+
arel (~> 7.0)
|
16
|
+
activesupport (5.0.3)
|
17
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
|
+
i18n (~> 0.7)
|
19
|
+
minitest (~> 5.1)
|
20
|
+
tzinfo (~> 1.1)
|
21
|
+
arel (7.1.4)
|
22
|
+
awesome_print (1.8.0)
|
23
|
+
byebug (9.0.6)
|
24
|
+
codeclimate-test-reporter (1.0.8)
|
25
|
+
simplecov (<= 0.13)
|
26
|
+
coderay (1.1.1)
|
27
|
+
concurrent-ruby (1.0.5)
|
28
|
+
docile (1.1.5)
|
29
|
+
i18n (0.8.4)
|
30
|
+
json (2.1.0)
|
31
|
+
metaclass (0.0.4)
|
32
|
+
method_source (0.8.2)
|
33
|
+
minitest (5.10.2)
|
34
|
+
minitest-utils (0.3.1)
|
35
|
+
minitest
|
36
|
+
mocha (1.2.1)
|
37
|
+
metaclass (~> 0.0.1)
|
38
|
+
pg (0.21.0)
|
39
|
+
pry (0.10.4)
|
40
|
+
coderay (~> 1.1.0)
|
41
|
+
method_source (~> 0.8.1)
|
42
|
+
slop (~> 3.4)
|
43
|
+
pry-byebug (3.4.2)
|
44
|
+
byebug (~> 9.0)
|
45
|
+
pry (~> 0.10)
|
46
|
+
pry-meta (0.0.10)
|
47
|
+
awesome_print
|
48
|
+
pry
|
49
|
+
pry-byebug
|
50
|
+
pry-remote
|
51
|
+
pry-remote (0.1.8)
|
52
|
+
pry (~> 0.9)
|
53
|
+
slop (~> 3.0)
|
54
|
+
rake (12.0.0)
|
55
|
+
simplecov (0.13.0)
|
56
|
+
docile (~> 1.1.0)
|
57
|
+
json (>= 1.8, < 3)
|
58
|
+
simplecov-html (~> 0.10.0)
|
59
|
+
simplecov-html (0.10.1)
|
60
|
+
slop (3.6.0)
|
61
|
+
thread_safe (0.3.6)
|
62
|
+
tzinfo (1.2.3)
|
63
|
+
thread_safe (~> 0.1)
|
64
|
+
|
65
|
+
PLATFORMS
|
66
|
+
ruby
|
67
|
+
|
68
|
+
DEPENDENCIES
|
69
|
+
activerecord (~> 5.0.0)
|
70
|
+
ar-uuid!
|
71
|
+
bundler
|
72
|
+
codeclimate-test-reporter
|
73
|
+
minitest-utils
|
74
|
+
mocha
|
75
|
+
pg
|
76
|
+
pry-meta
|
77
|
+
rake
|
78
|
+
|
79
|
+
BUNDLED WITH
|
80
|
+
1.15.1
|
@@ -0,0 +1,80 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
ar-uuid (0.1.2)
|
5
|
+
activerecord
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activemodel (5.1.1)
|
11
|
+
activesupport (= 5.1.1)
|
12
|
+
activerecord (5.1.1)
|
13
|
+
activemodel (= 5.1.1)
|
14
|
+
activesupport (= 5.1.1)
|
15
|
+
arel (~> 8.0)
|
16
|
+
activesupport (5.1.1)
|
17
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
|
+
i18n (~> 0.7)
|
19
|
+
minitest (~> 5.1)
|
20
|
+
tzinfo (~> 1.1)
|
21
|
+
arel (8.0.0)
|
22
|
+
awesome_print (1.8.0)
|
23
|
+
byebug (9.0.6)
|
24
|
+
codeclimate-test-reporter (1.0.8)
|
25
|
+
simplecov (<= 0.13)
|
26
|
+
coderay (1.1.1)
|
27
|
+
concurrent-ruby (1.0.5)
|
28
|
+
docile (1.1.5)
|
29
|
+
i18n (0.8.4)
|
30
|
+
json (2.1.0)
|
31
|
+
metaclass (0.0.4)
|
32
|
+
method_source (0.8.2)
|
33
|
+
minitest (5.10.2)
|
34
|
+
minitest-utils (0.3.1)
|
35
|
+
minitest
|
36
|
+
mocha (1.2.1)
|
37
|
+
metaclass (~> 0.0.1)
|
38
|
+
pg (0.21.0)
|
39
|
+
pry (0.10.4)
|
40
|
+
coderay (~> 1.1.0)
|
41
|
+
method_source (~> 0.8.1)
|
42
|
+
slop (~> 3.4)
|
43
|
+
pry-byebug (3.4.2)
|
44
|
+
byebug (~> 9.0)
|
45
|
+
pry (~> 0.10)
|
46
|
+
pry-meta (0.0.10)
|
47
|
+
awesome_print
|
48
|
+
pry
|
49
|
+
pry-byebug
|
50
|
+
pry-remote
|
51
|
+
pry-remote (0.1.8)
|
52
|
+
pry (~> 0.9)
|
53
|
+
slop (~> 3.0)
|
54
|
+
rake (12.0.0)
|
55
|
+
simplecov (0.13.0)
|
56
|
+
docile (~> 1.1.0)
|
57
|
+
json (>= 1.8, < 3)
|
58
|
+
simplecov-html (~> 0.10.0)
|
59
|
+
simplecov-html (0.10.1)
|
60
|
+
slop (3.6.0)
|
61
|
+
thread_safe (0.3.6)
|
62
|
+
tzinfo (1.2.3)
|
63
|
+
thread_safe (~> 0.1)
|
64
|
+
|
65
|
+
PLATFORMS
|
66
|
+
ruby
|
67
|
+
|
68
|
+
DEPENDENCIES
|
69
|
+
activerecord (~> 5.1.0)
|
70
|
+
ar-uuid!
|
71
|
+
bundler
|
72
|
+
codeclimate-test-reporter
|
73
|
+
minitest-utils
|
74
|
+
mocha
|
75
|
+
pg
|
76
|
+
pry-meta
|
77
|
+
rake
|
78
|
+
|
79
|
+
BUNDLED WITH
|
80
|
+
1.15.1
|
data/lib/active_record/uuid.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
module ActiveRecord
|
2
2
|
module UUID
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
3
|
+
require "active_record"
|
4
|
+
require "active_record/base"
|
5
|
+
require "active_record/uuid/version"
|
6
|
+
require "active_record/uuid/schema"
|
7
|
+
require "active_record/uuid/table_definition"
|
8
|
+
require "active_record/uuid/ext"
|
9
|
+
require "active_record/uuid/utils"
|
9
10
|
end
|
10
11
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
ActiveSupport.on_load(:active_record) do
|
2
|
-
require
|
2
|
+
require "active_record/connection_adapters/postgresql_adapter"
|
3
3
|
|
4
4
|
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.include ActiveRecord::UUID::Schema
|
5
5
|
ActiveRecord::ConnectionAdapters::PostgreSQL::TableDefinition.include ActiveRecord::UUID::TableDefinition
|
@@ -4,12 +4,18 @@ module ActiveRecord
|
|
4
4
|
def references(*args)
|
5
5
|
options = args.extract_options!
|
6
6
|
options[:type] = :uuid unless options.include?(:type)
|
7
|
+
options[:null] = !::ActiveRecord::UUID::Utils.belongs_to_required_by_default unless options.include?(:null)
|
7
8
|
args << options
|
8
9
|
|
9
10
|
super(*args)
|
10
11
|
end
|
11
12
|
|
12
13
|
alias_method :belongs_to, :references
|
14
|
+
|
15
|
+
def primary_key(name, type = :primary_key, **options)
|
16
|
+
options[:default] = ::ActiveRecord::UUID::Utils.uuid_default_function
|
17
|
+
super(name, type, **options)
|
18
|
+
end
|
13
19
|
end
|
14
20
|
end
|
15
21
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
module UUID
|
3
|
+
MissingExtensionError = Class.new(StandardError) do
|
4
|
+
def initialize
|
5
|
+
super(%[Use either `enable_extension "uuid-ossp"` or `enable_extension "pgcrypto"`])
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
module Utils
|
10
|
+
EXTENSIONS_SQL = <<-SQL.freeze
|
11
|
+
select
|
12
|
+
extname
|
13
|
+
from pg_extension
|
14
|
+
where
|
15
|
+
extname in ('uuid-ossp', 'pgcrypto')
|
16
|
+
order by 1
|
17
|
+
limit 1
|
18
|
+
SQL
|
19
|
+
|
20
|
+
FUNCTION_NAMES = {
|
21
|
+
"uuid-ossp" => "uuid_generate_v4()",
|
22
|
+
"pgcrypto" => "gen_random_uuid()"
|
23
|
+
}.freeze
|
24
|
+
|
25
|
+
def self.uuid_extname
|
26
|
+
connection = ::ActiveRecord::Base.connection
|
27
|
+
result = connection.execute(EXTENSIONS_SQL).first
|
28
|
+
raise MissingExtensionError unless result
|
29
|
+
result.fetch("extname")
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.uuid_default_function
|
33
|
+
FUNCTION_NAMES.fetch(uuid_extname)
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.belongs_to_required_by_default
|
37
|
+
if ::ActiveRecord::Base.respond_to?(:belongs_to_required_by_default)
|
38
|
+
::ActiveRecord::Base.belongs_to_required_by_default
|
39
|
+
else
|
40
|
+
false
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/ar-uuid.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require "active_record/uuid"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ar-uuid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nando Vieira
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -28,32 +28,46 @@ dependencies:
|
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: minitest-utils
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: mocha
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - ">="
|
@@ -94,8 +108,22 @@ dependencies:
|
|
94
108
|
- - ">="
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: codeclimate-test-reporter
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
97
125
|
description: Add UUID support for ActiveRecord. It enforces uuid primary keys, fixes
|
98
|
-
ActiveRecord
|
126
|
+
ActiveRecord"s first/last methods and more.
|
99
127
|
email:
|
100
128
|
- fnando.vieira@gmail.com
|
101
129
|
executables: []
|
@@ -103,20 +131,28 @@ extensions: []
|
|
103
131
|
extra_rdoc_files: []
|
104
132
|
files:
|
105
133
|
- ".gitignore"
|
106
|
-
- ".rspec"
|
107
134
|
- ".travis.yml"
|
108
135
|
- Gemfile
|
136
|
+
- LICENSE.txt
|
109
137
|
- README.md
|
110
138
|
- Rakefile
|
111
139
|
- ar-uuid.gemspec
|
140
|
+
- gemfiles/4_2.gemfile
|
141
|
+
- gemfiles/4_2.gemfile.lock
|
142
|
+
- gemfiles/5_0.gemfile
|
143
|
+
- gemfiles/5_0.gemfile.lock
|
144
|
+
- gemfiles/5_1.gemfile
|
145
|
+
- gemfiles/5_1.gemfile.lock
|
112
146
|
- lib/active_record/uuid.rb
|
113
147
|
- lib/active_record/uuid/ext.rb
|
114
148
|
- lib/active_record/uuid/schema.rb
|
115
149
|
- lib/active_record/uuid/table_definition.rb
|
150
|
+
- lib/active_record/uuid/utils.rb
|
116
151
|
- lib/active_record/uuid/version.rb
|
117
152
|
- lib/ar-uuid.rb
|
118
153
|
homepage: http://rubygems.org/gems/ar-uuid
|
119
|
-
licenses:
|
154
|
+
licenses:
|
155
|
+
- MIT
|
120
156
|
metadata: {}
|
121
157
|
post_install_message:
|
122
158
|
rdoc_options: []
|
@@ -126,7 +162,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
162
|
requirements:
|
127
163
|
- - ">="
|
128
164
|
- !ruby/object:Gem::Version
|
129
|
-
version:
|
165
|
+
version: '0'
|
130
166
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
167
|
requirements:
|
132
168
|
- - ">="
|
@@ -134,9 +170,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
170
|
version: '0'
|
135
171
|
requirements: []
|
136
172
|
rubyforge_project:
|
137
|
-
rubygems_version: 2.
|
173
|
+
rubygems_version: 2.6.11
|
138
174
|
signing_key:
|
139
175
|
specification_version: 4
|
140
|
-
summary: Add UUID support for ActiveRecord. It enforces uuid primary keys, fixes ActiveRecord
|
176
|
+
summary: Add UUID support for ActiveRecord. It enforces uuid primary keys, fixes ActiveRecord"s
|
141
177
|
first/last methods and more.
|
142
178
|
test_files: []
|
data/.rspec
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|