activerecord-pg_collation 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 398383f3e3a1e99867910103a6256203ba0a2123b5357a3930c448af26529731
4
- data.tar.gz: d6d648a2b6a67a2179a6b9f1ff27cb7fafbdb0380b7c237994c21d9ad0721528
3
+ metadata.gz: 60ae02aa38548a2088a52acfddddd24cac4d4f05f8cb0e43c841078adc4fe3c0
4
+ data.tar.gz: 0661777b08f3641a240282190704526c371625be2c148ad262a937386edc5f44
5
5
  SHA512:
6
- metadata.gz: ac837afd30918e39010b9a0e08980c875de1e22993281ec72cdce44c1bed767bbd1d581b52de896c8c5d071088ce3dedcc571b6bae8962f425e81cf4df6d8474
7
- data.tar.gz: bf11b8b6a64bf998d46ad91299a3dcf886440afa9966eb992925e2b8c5561683ca410ec9c78dbfd0128b4f85272747c19cc55940b758d67154689bd127ad3019
6
+ metadata.gz: 7df3e00404e4ec49e1530152bbacd4a1685e859b0a1cae0d23aa690b89c618ad8a7645a89fa9a130eaa80a9febefded0d0b8770af26f0fe9b8e0e4b81739b425
7
+ data.tar.gz: d8debd5687be23b79657b683b13afeb2becf99cfddbf9766e4d7fe1a08444672ba81cdaa736c024c8414ba512859b4687d1012d56c576ff306b13c8ee0fdd3d1
data/Gemfile CHANGED
@@ -5,12 +5,15 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in activerecord-pg_collation.gemspec
6
6
  gemspec
7
7
 
8
- gem "rake", "~> 13.0"
9
- gem "rspec", "~> 3.0"
10
- gem "rubocop", "~> 1.21"
11
8
  gem "pg", "~> 1.2", ">= 1.2.3"
12
9
  gem "activerecord", "~> 6.1", ">= 6.1.4.1"
13
10
  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"
11
+
12
+ group :development, :test do
13
+ gem "rubocop", "~> 1.21"
14
+ gem 'appraisal', '~> 2.4', '>= 2.4.1'
15
+ gem 'bundler', '~> 2.2', '>= 2.2.32'
16
+ gem "rake", "~> 13.0"
17
+ gem "rspec", "~> 3.0"
18
+ gem "pry"
19
+ end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- activerecord-pg_collation (0.1.1)
4
+ activerecord-pg_collation (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,8 +1,21 @@
1
- # Activerecord::PgCollation
1
+ # Activerecord::PGCollation
2
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.
3
+ This gem adds support for creating and deleting collations. The collation feature allows specifying the sort order and character classification behavior of data per-column, or even per-operation. This alleviates the restriction that the LC_COLLATE and LC_CTYPE settings of a database cannot be changed after its creation.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ ## schema.rb Support
6
+
7
+ The motivation of this gem is to integrate postgres collations into your `schema.rb` file without switching to `structure.sql`.
8
+
9
+ ```ruby
10
+ ActiveRecord::Schema.define(version: 2021_12_01_213707) do
11
+
12
+ # These are extensions that must be enabled in order to support this database
13
+ enable_extension "plpgsql"
14
+
15
+ # These are collations that must be created before they can be used in the schema definition
16
+ create_collation "case_insensitive", lc_collate: "und-u-ks-level2", lc_ctype: "und-u-ks-level2", provider: "icu", deterministic: false
17
+ end
18
+ ```
6
19
 
7
20
  ## Installation
8
21
 
@@ -22,22 +35,62 @@ Or install it yourself as:
22
35
 
23
36
  ## Usage
24
37
 
25
- TODO: Write usage instructions here
38
+ ### Create a collation
26
39
 
27
- ## Development
40
+ This gem adds the `create_collation` migration helper for creating collations:
28
41
 
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.
42
+ ```ruby
43
+ create_collation "collation_name", options
44
+ ```
30
45
 
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).
46
+ For more information about available options visit: https://www.postgresql.org/docs/current/sql-createcollation.html
32
47
 
33
- ## Contributing
48
+ For example, this migration creates a case insensitive collation:
34
49
 
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).
50
+ ```ruby
51
+ class CreateCaseInsensitiveCollation < ActiveRecord::Migration[6.1]
52
+ def change
53
+ create_collation "case_insensitive", provider: "icu", locale: "und-u-ks-level2", deterministic: false
54
+ end
55
+ end
56
+ ```
36
57
 
37
- ## License
58
+ ### Delete a collation
38
59
 
39
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
60
+ This gem adds the `drop_collation` migration helper for deleting collations:
61
+
62
+ ```ruby
63
+ drop_collation "collation_name", option
64
+ ```
40
65
 
41
- ## Code of Conduct
66
+ By default `option` is equals to `"RESTRICT"`. For more information visit https://www.postgresql.org/docs/current/sql-dropcollation.html
42
67
 
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).
68
+ For example, this migration deletes the case insensitive collation previously created:
69
+
70
+ ```ruby
71
+ class DropCaseInsensitiveCollation < ActiveRecord::Migration[6.1]
72
+ def change
73
+ drop_collation "case_insensitive"
74
+ end
75
+ end
76
+ ```
77
+
78
+ ### Use a collation with an index
79
+
80
+ ```ruby
81
+ class AddIndexToSomeTable < ActiveRecord::Migration[6.1]
82
+ def change
83
+ add_index :some_table, "some_string_field COLLATE case_insensitive, another_string_field COLLATE case_insensitive", unique: true
84
+ end
85
+ end
86
+ ```
87
+
88
+ ## Development
89
+
90
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
91
+
92
+ 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).
93
+
94
+ ## License
95
+
96
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module PGCollation
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-pg_collation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Axel Pontetto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-04 00:00:00.000000000 Z
11
+ date: 2021-12-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: