schema_plus_pg_indexes 0.3.0 → 0.3.1
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/README.md +1 -0
- data/lib/schema_plus_pg_indexes/middleware/postgresql/schema.rb +10 -3
- data/lib/schema_plus_pg_indexes/version.rb +1 -1
- data/spec/schema_dumper_spec.rb +27 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5586f2b3408a3890cc6967d852d27ce9644380f7
|
4
|
+
data.tar.gz: 7d22c43ab14375ce9b48106e2e380f1d19ed6564
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0e0425e6f627918c211b4ece0f892088dd1d4446a19dd26fac39bc26d10aebcae04acbe69f9d7d1a5c1a842242a6353de444c4a8eab448abaf61c03d8f90af3
|
7
|
+
data.tar.gz: e075301f4c44a74edf3bfe577663caeed80afb1288764e5c54ce88bb2c16fdd05be173cfdf1b671e2b2520689547de03b6791a730d19d8732422baa459c82be2
|
data/README.md
CHANGED
@@ -62,6 +62,7 @@ schema_plus_pg_indexes is tested on
|
|
62
62
|
|
63
63
|
## Release Notes
|
64
64
|
|
65
|
+
* v0.3.1 - Bug fix: schema dump for complex order clause (#19). Thanks to [@joxxoxo](https://github.com/joxxoxo).
|
65
66
|
* v0.3.0 - Added Rails 5.1.0 support
|
66
67
|
* v0.2.1 - Added Rails 5.0.1 support (Removed Rails 5.0.0 support)
|
67
68
|
* v0.2.0 - Added Rails 5 support (Removed Rails 4.2 support)
|
@@ -93,9 +93,16 @@ module SchemaPlusPgIndexes
|
|
93
93
|
]
|
94
94
|
operator_classes.delete_if{|k,v| v.nil?}
|
95
95
|
|
96
|
-
|
97
|
-
|
98
|
-
|
96
|
+
orders = {}
|
97
|
+
order_clause = inddef[/\((\w+[^)]+)\)\z/, 1]
|
98
|
+
if order_clause && (using.downcase == "btree")
|
99
|
+
order_clause.split(/,\s+/).each do |order_by_column|
|
100
|
+
match = /\A(\w+)\s*(.+)?\z/.match(order_by_column)
|
101
|
+
column, order = match[1], match[2] || 'asc'
|
102
|
+
order = order.downcase.to_sym if order && order =~ /\A(desc|asc)\z/i
|
103
|
+
orders[column] = order
|
104
|
+
end
|
105
|
+
end
|
99
106
|
|
100
107
|
::ActiveRecord::ConnectionAdapters::IndexDefinition.new(env.table_name, column_names,
|
101
108
|
name: index_name,
|
data/spec/schema_dumper_spec.rb
CHANGED
@@ -130,6 +130,33 @@ describe "Schema dump" do
|
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
133
|
+
it "should define index with order" do
|
134
|
+
with_index Post, [:str_short], order: 'desc' do
|
135
|
+
potential_lines = dump_posts.each_line.grep(/str_short/).join.strip
|
136
|
+
expect(potential_lines).to match(/t\.string\s+"str_short",\s+:index=>{:name=>"index_posts_on_str_short", :order=>{.*str_short.*=>:desc}}/)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should define index with order for multiple columns" do
|
141
|
+
with_index Post, [:str_short, :string_no_default], order: { str_short: :desc, string_no_default: :asc } do
|
142
|
+
potential_lines = dump_posts.each_line.grep(/str_short/).join.strip
|
143
|
+
expect(potential_lines).to match(/t\.string\s+"str_short",\s+:index=>{[^}]+:order=>{.*str_short.*=>:desc, .*string_no_default.*=>:asc}}/)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
it "should define index with order with NULLS specified" do
|
148
|
+
with_index Post, [:str_short], order: 'desc NULLS LAST' do
|
149
|
+
potential_lines = dump_posts.each_line.grep(/str_short/).join.strip
|
150
|
+
expect(potential_lines).to match(/t\.string\s+"str_short",\s+:index=>{[^}]+:order=>{.*str_short.*=>"DESC NULLS LAST"}}/)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should define index with order with NULLS specified for multiple columns" do
|
155
|
+
with_index Post, [:str_short, :string_no_default], order: { str_short: 'desc NULLS LAST', string_no_default: :desc } do
|
156
|
+
potential_lines = dump_posts.each_line.grep(/str_short/).join.strip
|
157
|
+
expect(potential_lines).to match(/t\.string\s+"str_short",\s+:index=>{[^}]+:order=>{.*str_short.*=>"DESC NULLS LAST", .*string_no_default.*=>:desc}}/)
|
158
|
+
end
|
159
|
+
end
|
133
160
|
|
134
161
|
it "should not define :case_sensitive => false with non-trivial expression" do
|
135
162
|
with_index Post, :name => "posts_user_body_index", :expression => "BTRIM(LOWER(body))" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schema_plus_pg_indexes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ronen barzel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07
|
11
|
+
date: 2017-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|