activerecord-pg_collation 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +13 -0
- data/Appraisals +3 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +91 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +44 -0
- data/activerecord-pg_collation.gemspec +41 -0
- data/bin/console +17 -0
- data/bin/setup +9 -0
- data/gemfiles/6.1.gemfile +15 -0
- data/gemfiles/6.1.gemfile.lock +90 -0
- data/lib/active_record/pg_collation/6.1/schema_dumper.rb +33 -0
- data/lib/active_record/pg_collation/command_recorder.rb +40 -0
- data/lib/active_record/pg_collation/postgresql_adapter.rb +22 -0
- data/lib/active_record/pg_collation/schema_statements.rb +39 -0
- data/lib/active_record/pg_collation/version.rb +5 -0
- data/lib/active_record/pg_collation.rb +62 -0
- data/lib/activerecord/pg_collation.rb +1 -0
- metadata +66 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9af200b93bf9e8a88059ef6c9d687e3db7cacd884afab5f0e87493b36df89bbf
|
4
|
+
data.tar.gz: 85aead27a2ae7b9ecaeff7efa70730ca2a0b92e6bf40c4ce1fd3fc4d043d2da7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6297d070a8a7b0b6ce886c9923f126167a7d9329199f700e6e96384fe8d338dca23a6714a83468eb092d5be636c56d52cf5d5eb4fa3a6edf4ed76106db6caa09
|
7
|
+
data.tar.gz: ebec8b5c26281560c6acfc3188a3b7fc9941e8cd50385a53be100693b5984ec8c9e6b542672c8cc0bf90b4a5cf01bc745eb7091d75cca490227d9c1d3bd82047
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/Appraisals
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at axelpontetto@hotmail.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in activerecord-pg_collation.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem "rake", "~> 13.0"
|
9
|
+
gem "rspec", "~> 3.0"
|
10
|
+
gem "rubocop", "~> 1.21"
|
11
|
+
gem "pg", "~> 1.2", ">= 1.2.3"
|
12
|
+
gem "activerecord", "~> 6.1", ">= 6.1.4.1"
|
13
|
+
gem "activesupport", "~> 6.1", ">= 6.1.4.1"
|
14
|
+
gem 'appraisal', '~> 2.4', '>= 2.4.1'
|
15
|
+
gem 'bundler', '~> 2.2', '>= 2.2.32'
|
16
|
+
gem "pry"
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
activerecord-pg_collation (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
activemodel (6.1.4.1)
|
10
|
+
activesupport (= 6.1.4.1)
|
11
|
+
activerecord (6.1.4.1)
|
12
|
+
activemodel (= 6.1.4.1)
|
13
|
+
activesupport (= 6.1.4.1)
|
14
|
+
activesupport (6.1.4.1)
|
15
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
16
|
+
i18n (>= 1.6, < 2)
|
17
|
+
minitest (>= 5.1)
|
18
|
+
tzinfo (~> 2.0)
|
19
|
+
zeitwerk (~> 2.3)
|
20
|
+
appraisal (2.4.1)
|
21
|
+
bundler
|
22
|
+
rake
|
23
|
+
thor (>= 0.14.0)
|
24
|
+
ast (2.4.2)
|
25
|
+
coderay (1.1.3)
|
26
|
+
concurrent-ruby (1.1.9)
|
27
|
+
diff-lcs (1.4.4)
|
28
|
+
i18n (1.8.11)
|
29
|
+
concurrent-ruby (~> 1.0)
|
30
|
+
method_source (1.0.0)
|
31
|
+
minitest (5.14.4)
|
32
|
+
parallel (1.21.0)
|
33
|
+
parser (3.0.2.0)
|
34
|
+
ast (~> 2.4.1)
|
35
|
+
pg (1.2.3)
|
36
|
+
pry (0.14.1)
|
37
|
+
coderay (~> 1.1)
|
38
|
+
method_source (~> 1.0)
|
39
|
+
rainbow (3.0.0)
|
40
|
+
rake (13.0.6)
|
41
|
+
regexp_parser (2.1.1)
|
42
|
+
rexml (3.2.5)
|
43
|
+
rspec (3.10.0)
|
44
|
+
rspec-core (~> 3.10.0)
|
45
|
+
rspec-expectations (~> 3.10.0)
|
46
|
+
rspec-mocks (~> 3.10.0)
|
47
|
+
rspec-core (3.10.1)
|
48
|
+
rspec-support (~> 3.10.0)
|
49
|
+
rspec-expectations (3.10.1)
|
50
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
51
|
+
rspec-support (~> 3.10.0)
|
52
|
+
rspec-mocks (3.10.2)
|
53
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
54
|
+
rspec-support (~> 3.10.0)
|
55
|
+
rspec-support (3.10.3)
|
56
|
+
rubocop (1.23.0)
|
57
|
+
parallel (~> 1.10)
|
58
|
+
parser (>= 3.0.0.0)
|
59
|
+
rainbow (>= 2.2.2, < 4.0)
|
60
|
+
regexp_parser (>= 1.8, < 3.0)
|
61
|
+
rexml
|
62
|
+
rubocop-ast (>= 1.12.0, < 2.0)
|
63
|
+
ruby-progressbar (~> 1.7)
|
64
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
65
|
+
rubocop-ast (1.13.0)
|
66
|
+
parser (>= 3.0.1.1)
|
67
|
+
ruby-progressbar (1.11.0)
|
68
|
+
thor (1.1.0)
|
69
|
+
tzinfo (2.0.4)
|
70
|
+
concurrent-ruby (~> 1.0)
|
71
|
+
unicode-display_width (2.1.0)
|
72
|
+
zeitwerk (2.5.1)
|
73
|
+
|
74
|
+
PLATFORMS
|
75
|
+
x86_64-darwin-19
|
76
|
+
x86_64-linux
|
77
|
+
|
78
|
+
DEPENDENCIES
|
79
|
+
activerecord (~> 6.1, >= 6.1.4.1)
|
80
|
+
activerecord-pg_collation!
|
81
|
+
activesupport (~> 6.1, >= 6.1.4.1)
|
82
|
+
appraisal (~> 2.4, >= 2.4.1)
|
83
|
+
bundler (~> 2.2, >= 2.2.32)
|
84
|
+
pg (~> 1.2, >= 1.2.3)
|
85
|
+
pry
|
86
|
+
rake (~> 13.0)
|
87
|
+
rspec (~> 3.0)
|
88
|
+
rubocop (~> 1.21)
|
89
|
+
|
90
|
+
BUNDLED WITH
|
91
|
+
2.2.32
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 Axel Pontetto
|
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
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Activerecord::PgCollation
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/activerecord/pg_collation`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'activerecord-pg_collation'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install activerecord-pg_collation
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/activerecord-pg_collation. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/activerecord-pg_collation/blob/master/CODE_OF_CONDUCT.md).
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
40
|
+
|
41
|
+
## Code of Conduct
|
42
|
+
|
43
|
+
Everyone interacting in the Activerecord::PgCollation project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/activerecord-pg_collation/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
require "appraisal"
|
4
|
+
|
5
|
+
if !ENV["APPRAISAL_INITIALIZED"] && !ENV["TRAVIS"]
|
6
|
+
task :default => :appraisal
|
7
|
+
else
|
8
|
+
task :default => :spec
|
9
|
+
end
|
10
|
+
|
11
|
+
task :connection do
|
12
|
+
require "active_record"
|
13
|
+
require_relative "spec/support/connection_config"
|
14
|
+
|
15
|
+
config = db_config_hash.except(:database)
|
16
|
+
|
17
|
+
if ActiveRecord.constants.include?(:DatabaseConfigurations)
|
18
|
+
config = ActiveRecord::DatabaseConfigurations::HashConfig.new("test", "primary", config)
|
19
|
+
end
|
20
|
+
|
21
|
+
ActiveRecord::Base.establish_connection(config)
|
22
|
+
end
|
23
|
+
|
24
|
+
namespace :spec do
|
25
|
+
RSpec::Core::RakeTask.new(:run)
|
26
|
+
|
27
|
+
desc "Setup the Database for testing"
|
28
|
+
task setup: [:connection] do
|
29
|
+
ActiveRecord::Base.connection_pool.with_connection do |conn|
|
30
|
+
conn.create_database ENV.fetch("TEST_DATABASE", "pg_collation_test"), owner: ENV.fetch("TEST_USER") { ENV.fetch("USER", "pg_collation") }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "Discard the test database"
|
35
|
+
task teardown: [:connection] do
|
36
|
+
ActiveRecord::Base.connection_pool.with_connection do |conn|
|
37
|
+
conn.drop_database ENV.fetch("TEST_DATABASE", "pg_collation_test")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
task reset: [:teardown, :setup]
|
42
|
+
end
|
43
|
+
|
44
|
+
task spec: %w[spec:setup spec:run spec:teardown]
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "active_record/pg_collation/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "activerecord-pg_collation"
|
9
|
+
spec.version = ActiveRecord::PGCollation::VERSION
|
10
|
+
spec.authors = ["Axel Pontetto"]
|
11
|
+
spec.email = ["axelpontetto@hotmail.com"]
|
12
|
+
|
13
|
+
spec.summary = "Write a short summary, because RubyGems requires one."
|
14
|
+
# spec.description = "TODO: Write a longer description or delete this line."
|
15
|
+
# spec.homepage = "TODO: Put your gem's website or public repo URL here."
|
16
|
+
spec.license = "MIT"
|
17
|
+
spec.required_ruby_version = ">= 2.6.0"
|
18
|
+
|
19
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
20
|
+
|
21
|
+
# spec.metadata["homepage_uri"] = spec.homepage
|
22
|
+
# spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
|
23
|
+
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
24
|
+
|
25
|
+
# Specify which files should be added to the gem when it is released.
|
26
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
27
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
28
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
29
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
30
|
+
end
|
31
|
+
end
|
32
|
+
spec.bindir = "exe"
|
33
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
34
|
+
spec.require_paths = ["lib"]
|
35
|
+
|
36
|
+
# Uncomment to register a new dependency of your gem
|
37
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
38
|
+
|
39
|
+
# For more information and examples about making a new gem, checkout our
|
40
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
41
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "activerecord/pg_collation"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
ActiveSupport.run_load_hooks(:active_record, ActiveRecord::Base)
|
11
|
+
|
12
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
13
|
+
require "pry"
|
14
|
+
Pry.start
|
15
|
+
|
16
|
+
require "irb"
|
17
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rake", "~> 13.0"
|
6
|
+
gem "rspec", "~> 3.0"
|
7
|
+
gem "rubocop", "~> 1.21"
|
8
|
+
gem "pg", "~> 1.2", ">= 1.2.3"
|
9
|
+
gem "activerecord", "~> 6.1"
|
10
|
+
gem "activesupport", "~> 6.1", ">= 6.1.4.1"
|
11
|
+
gem "appraisal", "~> 2.4", ">= 2.4.1"
|
12
|
+
gem "bundler", "~> 2.2", ">= 2.2.32"
|
13
|
+
gem "pry"
|
14
|
+
|
15
|
+
gemspec path: "../"
|
@@ -0,0 +1,90 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
activerecord-pg_collation (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
activemodel (6.1.4.1)
|
10
|
+
activesupport (= 6.1.4.1)
|
11
|
+
activerecord (6.1.4.1)
|
12
|
+
activemodel (= 6.1.4.1)
|
13
|
+
activesupport (= 6.1.4.1)
|
14
|
+
activesupport (6.1.4.1)
|
15
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
16
|
+
i18n (>= 1.6, < 2)
|
17
|
+
minitest (>= 5.1)
|
18
|
+
tzinfo (~> 2.0)
|
19
|
+
zeitwerk (~> 2.3)
|
20
|
+
appraisal (2.4.1)
|
21
|
+
bundler
|
22
|
+
rake
|
23
|
+
thor (>= 0.14.0)
|
24
|
+
ast (2.4.2)
|
25
|
+
coderay (1.1.3)
|
26
|
+
concurrent-ruby (1.1.9)
|
27
|
+
diff-lcs (1.4.4)
|
28
|
+
i18n (1.8.11)
|
29
|
+
concurrent-ruby (~> 1.0)
|
30
|
+
method_source (1.0.0)
|
31
|
+
minitest (5.14.4)
|
32
|
+
parallel (1.21.0)
|
33
|
+
parser (3.0.2.0)
|
34
|
+
ast (~> 2.4.1)
|
35
|
+
pg (1.2.3)
|
36
|
+
pry (0.14.1)
|
37
|
+
coderay (~> 1.1)
|
38
|
+
method_source (~> 1.0)
|
39
|
+
rainbow (3.0.0)
|
40
|
+
rake (13.0.6)
|
41
|
+
regexp_parser (2.1.1)
|
42
|
+
rexml (3.2.5)
|
43
|
+
rspec (3.10.0)
|
44
|
+
rspec-core (~> 3.10.0)
|
45
|
+
rspec-expectations (~> 3.10.0)
|
46
|
+
rspec-mocks (~> 3.10.0)
|
47
|
+
rspec-core (3.10.1)
|
48
|
+
rspec-support (~> 3.10.0)
|
49
|
+
rspec-expectations (3.10.1)
|
50
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
51
|
+
rspec-support (~> 3.10.0)
|
52
|
+
rspec-mocks (3.10.2)
|
53
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
54
|
+
rspec-support (~> 3.10.0)
|
55
|
+
rspec-support (3.10.3)
|
56
|
+
rubocop (1.23.0)
|
57
|
+
parallel (~> 1.10)
|
58
|
+
parser (>= 3.0.0.0)
|
59
|
+
rainbow (>= 2.2.2, < 4.0)
|
60
|
+
regexp_parser (>= 1.8, < 3.0)
|
61
|
+
rexml
|
62
|
+
rubocop-ast (>= 1.12.0, < 2.0)
|
63
|
+
ruby-progressbar (~> 1.7)
|
64
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
65
|
+
rubocop-ast (1.13.0)
|
66
|
+
parser (>= 3.0.1.1)
|
67
|
+
ruby-progressbar (1.11.0)
|
68
|
+
thor (1.1.0)
|
69
|
+
tzinfo (2.0.4)
|
70
|
+
concurrent-ruby (~> 1.0)
|
71
|
+
unicode-display_width (2.1.0)
|
72
|
+
zeitwerk (2.5.1)
|
73
|
+
|
74
|
+
PLATFORMS
|
75
|
+
x86_64-darwin-19
|
76
|
+
|
77
|
+
DEPENDENCIES
|
78
|
+
activerecord (~> 6.1)
|
79
|
+
activerecord-pg_collation!
|
80
|
+
activesupport (~> 6.1, >= 6.1.4.1)
|
81
|
+
appraisal (~> 2.4, >= 2.4.1)
|
82
|
+
bundler (~> 2.2, >= 2.2.32)
|
83
|
+
pg (~> 1.2, >= 1.2.3)
|
84
|
+
pry
|
85
|
+
rake (~> 13.0)
|
86
|
+
rspec (~> 3.0)
|
87
|
+
rubocop (~> 1.21)
|
88
|
+
|
89
|
+
BUNDLED WITH
|
90
|
+
2.2.32
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
module PGCollation
|
3
|
+
register :schema_dumper do
|
4
|
+
require "active_record/connection_adapters/postgresql/schema_dumper"
|
5
|
+
ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaDumper.prepend(SchemaDumper)
|
6
|
+
end
|
7
|
+
|
8
|
+
module SchemaDumper
|
9
|
+
private
|
10
|
+
|
11
|
+
def extensions(stream)
|
12
|
+
super
|
13
|
+
collations(stream)
|
14
|
+
end
|
15
|
+
|
16
|
+
def collations(stream)
|
17
|
+
collations = @connection.collations
|
18
|
+
|
19
|
+
if collations.any?
|
20
|
+
stream.puts(%Q{ # These are collations that must be created before they can be used in the schema definition})
|
21
|
+
collations.each do |collation|
|
22
|
+
name = collation["name"]
|
23
|
+
deterministic = collation["deterministic"]
|
24
|
+
options = collation.except("name", "deterministic").map {|k,v| %Q{#{k}: "#{v}"}}.join(", ")
|
25
|
+
stream.puts(%Q{ create_collation "#{name}", #{options}, deterministic: #{deterministic}})
|
26
|
+
end
|
27
|
+
stream.puts
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
module PGCollation
|
3
|
+
register :command_recorder do
|
4
|
+
require "active_record/migration/command_recorder"
|
5
|
+
ActiveRecord::Migration::CommandRecorder.include(CommandRecorder)
|
6
|
+
end
|
7
|
+
|
8
|
+
# ActiveRecord::Migration::CommandRecorder is a class used by reversible migrations.
|
9
|
+
# It captures the forward migration commands and translates them into their inverse
|
10
|
+
# by way of some simple metaprogramming.
|
11
|
+
#
|
12
|
+
# The Migrator class uses CommandRecorder during the reverse migration instead of
|
13
|
+
# the connection object. Forward migration calls are translated to their inverse
|
14
|
+
# where possible, and then forwarded to the connetion. Irreversible migrations
|
15
|
+
# raise an exception.
|
16
|
+
#
|
17
|
+
# Known schema statement methods are metaprogrammed into an inverse method like so:
|
18
|
+
#
|
19
|
+
# create_table => invert_create_table
|
20
|
+
#
|
21
|
+
# which returns:
|
22
|
+
#
|
23
|
+
# [:drop_table, args.first]
|
24
|
+
module CommandRecorder
|
25
|
+
def create_collation(*args, &block)
|
26
|
+
record(:create_collation, args, &block)
|
27
|
+
end
|
28
|
+
|
29
|
+
def create_collation_from(*args, &block)
|
30
|
+
record(:create_collation_from, args, &block)
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def invert_create_collation(args)
|
36
|
+
[:drop_collation, args]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
module PGCollation
|
3
|
+
register :postgresql_adapter do
|
4
|
+
require "active_record/connection_adapters/postgresql_adapter"
|
5
|
+
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.include(::ActiveRecord::PGCollation::PostgreSQLAdapter)
|
6
|
+
end
|
7
|
+
|
8
|
+
module PostgreSQLAdapter
|
9
|
+
# Helper method used by the monkeypatch internals. Provides an array of collations as they exist currently.
|
10
|
+
def collations
|
11
|
+
provider_mapping = {"i" => "icu", "c" => "libc", "d" => "libc"}
|
12
|
+
result = ActiveRecord::Base.connection.exec_query(<<-SQL.strip_heredoc, "SCHEMA")
|
13
|
+
SELECT c.collname AS name, c.collcollate AS lc_collate, c.collctype AS lc_ctype, c.collprovider AS provider, c.collisdeterministic AS deterministic, c.collversion AS version
|
14
|
+
FROM pg_collation c
|
15
|
+
JOIN pg_catalog.pg_namespace n ON n.oid = c.collnamespace
|
16
|
+
WHERE n.nspname = ANY (current_schemas(false))
|
17
|
+
SQL
|
18
|
+
result.to_a.sort_by {|h| h["name"]}.each {|h| h["provider"] = provider_mapping[h["provider"]]}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
module PGCollation
|
3
|
+
register :schema_statements do
|
4
|
+
require "active_record/connection_adapters/postgresql/schema_statements"
|
5
|
+
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.include(SchemaStatements)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
module SchemaStatements
|
10
|
+
# Create a collation
|
11
|
+
#
|
12
|
+
# CREATE COLLATION [ IF NOT EXISTS ] name (
|
13
|
+
# [ LOCALE = locale, ]
|
14
|
+
# [ LC_COLLATE = lc_collate, ]
|
15
|
+
# [ LC_CTYPE = lc_ctype, ]
|
16
|
+
# [ PROVIDER = provider, ]
|
17
|
+
# [ DETERMINISTIC = boolean, ]
|
18
|
+
# [ VERSION = version ]
|
19
|
+
# )
|
20
|
+
def create_collation(name, options = {})
|
21
|
+
query_options = options.map {|k,v| %Q{#{k} = '#{v}'} }.join(", ")
|
22
|
+
execute(%Q{CREATE COLLATION IF NOT EXISTS #{name} (#{query_options})}).tap {reload_type_map}
|
23
|
+
end
|
24
|
+
|
25
|
+
# Create a collation from
|
26
|
+
#
|
27
|
+
# CREATE COLLATION [ IF NOT EXISTS ] name FROM existing_collation
|
28
|
+
def create_collation_from(name, existing_collation)
|
29
|
+
execute(%Q{CREATE COLLATION IF NOT EXISTS #{name} FROM "#{existing_collation}"}).tap {reload_type_map}
|
30
|
+
end
|
31
|
+
|
32
|
+
# Drop a collation
|
33
|
+
#
|
34
|
+
# DROP COLLATION [ IF EXISTS ] name [ CASCADE | RESTRICT ]
|
35
|
+
def drop_collation(name, option = "RESTRICT")
|
36
|
+
execute(%Q{DROP COLLATION IF EXISTS #{name} #{option}}).tap {reload_type_map}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require "active_record"
|
2
|
+
require "active_support/lazy_load_hooks"
|
3
|
+
|
4
|
+
module ActiveRecord
|
5
|
+
module PGCollation
|
6
|
+
KNOWN_VERSIONS = %w[6.1].map { |v| Gem::Version.new(v) }
|
7
|
+
|
8
|
+
class << self
|
9
|
+
attr_reader :enabled_version
|
10
|
+
|
11
|
+
def install(version)
|
12
|
+
@enabled_version = approximate_version(version)
|
13
|
+
|
14
|
+
# Don't immediately fail if we don't yet support the current version.
|
15
|
+
# There's at least a chance it could work.
|
16
|
+
if !KNOWN_VERSIONS.include?(enabled_version) && enabled_version > KNOWN_VERSIONS.last
|
17
|
+
@enabled_version = KNOWN_VERSIONS.last
|
18
|
+
warn("[PGCollation] Current ActiveRecord version unsupported! Falling back to: #{enabled_version}")
|
19
|
+
end
|
20
|
+
|
21
|
+
initialize!
|
22
|
+
end
|
23
|
+
|
24
|
+
def register(patch, &block)
|
25
|
+
monkeypatches[patch] = block
|
26
|
+
end
|
27
|
+
|
28
|
+
def detected_version
|
29
|
+
approximate_version(Gem.loaded_specs["activerecord"].version)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def approximate_version(version)
|
35
|
+
segments = version.respond_to?(:canonical_segments) ? version.canonical_segments.dup : version.segments
|
36
|
+
|
37
|
+
segments.pop while segments.any? {|s| String === s}
|
38
|
+
segments.pop while segments.size > 2
|
39
|
+
segments.push(0) while segments.size < 2
|
40
|
+
|
41
|
+
Gem::Version.new(segments.join("."))
|
42
|
+
end
|
43
|
+
|
44
|
+
def monkeypatches
|
45
|
+
@patches ||= {}
|
46
|
+
end
|
47
|
+
|
48
|
+
def initialize!
|
49
|
+
require "active_record/pg_collation/command_recorder"
|
50
|
+
require "active_record/pg_collation/postgresql_adapter"
|
51
|
+
require "active_record/pg_collation/schema_statements"
|
52
|
+
|
53
|
+
Dir[File.join(__dir__, "pg_collation", enabled_version.to_s, "*.rb")].each {|file| require file}
|
54
|
+
monkeypatches.keys.each {|patch| monkeypatches.delete(patch).call}
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
ActiveSupport.on_load(:active_record) do
|
61
|
+
ActiveRecord::PGCollation.install(Gem.loaded_specs["activerecord"].version)
|
62
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "active_record/pg_collation"
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: activerecord-pg_collation
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Axel Pontetto
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-12-03 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
- axelpontetto@hotmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".rspec"
|
21
|
+
- ".rubocop.yml"
|
22
|
+
- Appraisals
|
23
|
+
- CHANGELOG.md
|
24
|
+
- CODE_OF_CONDUCT.md
|
25
|
+
- Gemfile
|
26
|
+
- Gemfile.lock
|
27
|
+
- LICENSE.txt
|
28
|
+
- README.md
|
29
|
+
- Rakefile
|
30
|
+
- activerecord-pg_collation.gemspec
|
31
|
+
- bin/console
|
32
|
+
- bin/setup
|
33
|
+
- gemfiles/6.1.gemfile
|
34
|
+
- gemfiles/6.1.gemfile.lock
|
35
|
+
- lib/active_record/pg_collation.rb
|
36
|
+
- lib/active_record/pg_collation/6.1/schema_dumper.rb
|
37
|
+
- lib/active_record/pg_collation/command_recorder.rb
|
38
|
+
- lib/active_record/pg_collation/postgresql_adapter.rb
|
39
|
+
- lib/active_record/pg_collation/schema_statements.rb
|
40
|
+
- lib/active_record/pg_collation/version.rb
|
41
|
+
- lib/activerecord/pg_collation.rb
|
42
|
+
homepage:
|
43
|
+
licenses:
|
44
|
+
- MIT
|
45
|
+
metadata:
|
46
|
+
allowed_push_host: https://rubygems.org
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 2.6.0
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubygems_version: 3.2.32
|
63
|
+
signing_key:
|
64
|
+
specification_version: 4
|
65
|
+
summary: Write a short summary, because RubyGems requires one.
|
66
|
+
test_files: []
|