schema_plus 1.8.7 → 1.8.8
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/CHANGELOG.md +4 -0
- data/README.md +2 -2
- data/lib/schema_plus/active_record/connection_adapters/postgresql_adapter.rb +15 -6
- data/lib/schema_plus/version.rb +1 -1
- data/schema_plus.gemspec +1 -1
- data/spec/index_spec.rb +5 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf8e4b864566ead9c19844204623de10e2ab44df
|
4
|
+
data.tar.gz: 71de29b1196886aa34275654f2a17d7b350585c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f65586a99e11078912f78c57778a2f4f133e7b6107b992eaf1753a9b7a59bd2fd0d48ede133f5aee0b48fd2e24ea7b4d1476467bfca482c22efc54ed1d10fc74
|
7
|
+
data.tar.gz: 5571cc83bf774b15bccafc15550af99d4cf1ed3e80dada6d3200f757a460b496171cea0cd40b3f85d6a1445c3a0d4ad5d5c03d025ee0dcf6de9416ad304b1e8b
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
## Change Log
|
4
4
|
|
5
|
+
## 1.8.8
|
6
|
+
|
7
|
+
* Bug fix: Postgres index creation was ignoring option `algorithm: :concurrently` (#209)
|
8
|
+
|
5
9
|
## 1.8.7
|
6
10
|
|
7
11
|
* Bug fix: Postgres schema dump failed when using case_sensitive => false and operator_class together (#204). Thanks to [@mikeauclair](https://github.com/mikeauclair)
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
> ## This is the README for schema_plus 1.8.x
|
2
|
-
> which supports Rails 3.2, 4.0, 4.1, and 4.2. Ongoing development towards schema_plus 2.0 takes place in the [master branch](https://github.com/SchemaPlus/schema_plus/tree/master), supporting only Rails >= 4.2
|
2
|
+
> which supports Rails 3.2, 4.0, 4.1, and 4.2.0. Ongoing development towards schema_plus 2.0 takes place in the [master branch](https://github.com/SchemaPlus/schema_plus/tree/master), supporting only Rails >= 4.2
|
3
3
|
|
4
4
|
---
|
5
5
|
|
@@ -24,7 +24,7 @@ For added rails DRYness see also the gems
|
|
24
24
|
|
25
25
|
SchemaPlus supports all combinations of:
|
26
26
|
|
27
|
-
* Rails/ActiveRecord 3.2, 4.0, 4.1, and 4.2
|
27
|
+
* Rails/ActiveRecord 3.2, 4.0, 4.1, and 4.2.0
|
28
28
|
* PostgreSQL, MySQL (using mysql2 gem; mysql gem only supported with Rails
|
29
29
|
3.2), or SQLite3 (using sqlite3 >= 3.7.7 for foreign key support, >= 3.8 for partial indexes)
|
30
30
|
* MRI Ruby >= 1.9.3
|
@@ -102,8 +102,9 @@ module SchemaPlus
|
|
102
102
|
raise ArgumentError, "Index name not given. Pass :name option" unless options[:name]
|
103
103
|
end
|
104
104
|
|
105
|
-
index_type = options[:unique] ? "UNIQUE" :
|
105
|
+
index_type = options[:unique] ? "UNIQUE" : nil
|
106
106
|
index_name = options[:name] || index_name(table_name, column_names)
|
107
|
+
concurrently = options[:algorithm] == :concurrently
|
107
108
|
conditions = options[:conditions]
|
108
109
|
kind = options[:kind]
|
109
110
|
operator_classes = options[:operator_class]
|
@@ -111,14 +112,22 @@ module SchemaPlus
|
|
111
112
|
operator_classes = Hash[column_names.map {|name| [name, operator_classes]}]
|
112
113
|
end
|
113
114
|
|
115
|
+
sql = []
|
116
|
+
sql << 'CREATE'
|
117
|
+
sql << index_type
|
118
|
+
sql << 'INDEX'
|
119
|
+
sql << 'CONCURRENTLY' if concurrently
|
120
|
+
sql << quote_column_name(index_name)
|
121
|
+
sql << 'ON'
|
122
|
+
sql << quote_table_name(table_name)
|
123
|
+
|
114
124
|
if expression = options[:expression] then
|
115
125
|
raise ArgumentError, "Cannot specify :case_sensitive => false with an expression. Use LOWER(column_name)" if options[:case_sensitive] == false
|
116
126
|
# Wrap expression in parentheses if necessary
|
117
127
|
expression = "(#{expression})" if expression !~ /(using|with|tablespace|where)/i
|
118
128
|
expression = "USING #{kind} #{expression}" if kind
|
119
129
|
expression = "#{expression} WHERE #{conditions}" if conditions
|
120
|
-
|
121
|
-
sql = "CREATE #{index_type} INDEX #{quote_column_name(index_name)} ON #{quote_table_name(table_name)} #{expression}"
|
130
|
+
sql << expression
|
122
131
|
else
|
123
132
|
option_strings = Hash[column_names.map {|name| [name, '']}]
|
124
133
|
(operator_classes||{}).each do |column, opclass|
|
@@ -138,10 +147,10 @@ module SchemaPlus
|
|
138
147
|
expression = "(#{quoted_column_names.join(', ')})"
|
139
148
|
expression = "USING #{kind} #{expression}" if kind
|
140
149
|
|
141
|
-
sql
|
142
|
-
sql
|
150
|
+
sql << expression
|
151
|
+
sql << "WHERE (#{ ::ActiveRecord::Base.send(:sanitize_sql, conditions, quote_table_name(table_name)) })" if conditions
|
143
152
|
end
|
144
|
-
execute sql
|
153
|
+
execute sql.compact.join(' ')
|
145
154
|
rescue => e
|
146
155
|
SchemaStatements.add_index_exception_handler(self, table_name, column_names, options, e)
|
147
156
|
end
|
data/lib/schema_plus/version.rb
CHANGED
data/schema_plus.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
22
|
s.require_paths = ["lib"]
|
23
23
|
|
24
|
-
s.add_dependency("activerecord", ">= 3.2", "
|
24
|
+
s.add_dependency("activerecord", ">= 3.2", "<= 4.2.0")
|
25
25
|
s.add_dependency("valuable")
|
26
26
|
|
27
27
|
s.add_development_dependency("schema_dev", "~> 1.4")
|
data/spec/index_spec.rb
CHANGED
@@ -61,6 +61,11 @@ describe "index" do
|
|
61
61
|
expect(index_for([:login, :deleted_at]).orders).to eq({"login" => :desc, "deleted_at" => :asc})
|
62
62
|
end
|
63
63
|
|
64
|
+
it "should respect algorithm: :concurrently", :postgresql => :only do
|
65
|
+
expect(connection).to receive(:execute).with(/CREATE INDEX CONCURRENTLY/)
|
66
|
+
add_index(:users, :login, :algorithm => :concurrently)
|
67
|
+
end if ActiveRecord::VERSION::MAJOR > 3
|
68
|
+
|
64
69
|
context "for duplicate index" do
|
65
70
|
it "should not complain if the index is the same" do
|
66
71
|
add_index(:users, :login)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schema_plus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ronen Barzel
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-03-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -18,9 +18,9 @@ dependencies:
|
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '3.2'
|
21
|
-
- - "
|
21
|
+
- - "<="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version:
|
23
|
+
version: 4.2.0
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -28,9 +28,9 @@ dependencies:
|
|
28
28
|
- - ">="
|
29
29
|
- !ruby/object:Gem::Version
|
30
30
|
version: '3.2'
|
31
|
-
- - "
|
31
|
+
- - "<="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 4.2.0
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: valuable
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|