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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dceee81f9c7bd38bbbc3f07765b6cc0318d13efe
4
- data.tar.gz: dbccc00e2a96548bd1a1aee0650dea2f07cbb791
3
+ metadata.gz: bf8e4b864566ead9c19844204623de10e2ab44df
4
+ data.tar.gz: 71de29b1196886aa34275654f2a17d7b350585c2
5
5
  SHA512:
6
- metadata.gz: 952c02e9cafdc50a2ae72221ec1f8a2011b9bc96541a85f02265100c9cfca51a3fc83dbde3d4a6bc11683aa440ff8ed7d8cc6b70829effca31d9cb4425d24b07
7
- data.tar.gz: 01cd8a88036ce14e328b6754a51eb4b44f6ae2384e05b11ea01843033301cb0e2fab2cf32a1013e27b55e7a38bc2043f40c5fb519712acc534d9eb6a8351a446
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 = "CREATE #{index_type} INDEX #{quote_column_name(index_name)} ON #{quote_table_name(table_name)} #{expression}"
142
- sql += " WHERE (#{ ::ActiveRecord::Base.send(:sanitize_sql, conditions, quote_table_name(table_name)) })" if conditions
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
@@ -1,3 +1,3 @@
1
1
  module SchemaPlus
2
- VERSION = "1.8.7"
2
+ VERSION = "1.8.8"
3
3
  end
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", "< 4.3")
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.7
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-02-13 00:00:00.000000000 Z
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: '4.3'
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: '4.3'
33
+ version: 4.2.0
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: valuable
36
36
  requirement: !ruby/object:Gem::Requirement