activerecord-pg_collation 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +9 -6
- data/Gemfile.lock +1 -1
- data/README.md +66 -13
- data/lib/active_record/pg_collation/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60ae02aa38548a2088a52acfddddd24cac4d4f05f8cb0e43c841078adc4fe3c0
|
4
|
+
data.tar.gz: 0661777b08f3641a240282190704526c371625be2c148ad262a937386edc5f44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
15
|
-
|
16
|
-
gem "
|
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
data/README.md
CHANGED
@@ -1,8 +1,21 @@
|
|
1
|
-
# Activerecord::
|
1
|
+
# Activerecord::PGCollation
|
2
2
|
|
3
|
-
|
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
|
-
|
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
|
-
|
38
|
+
### Create a collation
|
26
39
|
|
27
|
-
|
40
|
+
This gem adds the `create_collation` migration helper for creating collations:
|
28
41
|
|
29
|
-
|
42
|
+
```ruby
|
43
|
+
create_collation "collation_name", options
|
44
|
+
```
|
30
45
|
|
31
|
-
|
46
|
+
For more information about available options visit: https://www.postgresql.org/docs/current/sql-createcollation.html
|
32
47
|
|
33
|
-
|
48
|
+
For example, this migration creates a case insensitive collation:
|
34
49
|
|
35
|
-
|
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
|
-
|
58
|
+
### Delete a collation
|
38
59
|
|
39
|
-
|
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
|
-
|
66
|
+
By default `option` is equals to `"RESTRICT"`. For more information visit https://www.postgresql.org/docs/current/sql-dropcollation.html
|
42
67
|
|
43
|
-
|
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).
|
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.
|
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-
|
11
|
+
date: 2021-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|