schema_plus_pg_indexes 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a32103d4c7753e4551e51ed658016996e2cdc180
4
- data.tar.gz: edf9dddc470db8759c183b18d33df4f649dc32f1
3
+ metadata.gz: 54562a8d42de79c647bd53129db15ea7d7ba28a8
4
+ data.tar.gz: 58c89fd5d525991ec196991984e197fdbe6e2f5d
5
5
  SHA512:
6
- metadata.gz: 3e304b33918637897b17bb7518f6d962849ed17a2a1606a994a7159c3d9f4a1489abbb8f1d174660c896f3f4f44cfe0083f8480f74cab6b925062e14ae1f0e7a
7
- data.tar.gz: 774d15bd7fce97f4d39926310c36457861bb44533219b19a9a5f936e8eca9d40e00ded2e9b871971c2fe0209e7271c8eaacdc9f29905e903a9d5d80f0ade2299
6
+ metadata.gz: a4484ac41d541b88d0e153ab45ca72a5fbfc1229da39dc3e743d63688761266580d26ed5e7563f2da2032f447f6971dbae31224e0599a4777f780129d721f900
7
+ data.tar.gz: 382626aa0c5ae82cc0fb9e6465e66ee7b6f48c205f034e1ff5dfd2af84057bb8b611fd9c0fc02fee48b2c1c170b4b683e1b943a1cdabd74a49021b84a173e773
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/schema_plus_pg_indexes.svg)](http://badge.fury.io/rb/schema_plus_pg_indexes)
2
2
  [![Build Status](https://secure.travis-ci.org/SchemaPlus/schema_plus_pg_indexes.svg)](http://travis-ci.org/SchemaPlus/schema_plus_pg_indexes)
3
3
  [![Coverage Status](https://img.shields.io/coveralls/SchemaPlus/schema_plus_pg_indexes.svg)](https://coveralls.io/r/SchemaPlus/schema_plus_pg_indexes)
4
- [![Dependency Status](https://gemnasium.com/lomba/schema_plus_pg_indexes.svg)](https://gemnasium.com/SchemaPlus/schema_plus_pg_indexes)
4
+ [![Dependency Status](https://gemnasium.com/SchemaPlus/schema_plus_pg_indexes.svg)](https://gemnasium.com/SchemaPlus/schema_plus_pg_indexes)
5
5
 
6
6
  # schema_plus_pg_indexes
7
7
 
@@ -61,7 +61,8 @@ schema_plus_pg_indexes is tested on
61
61
 
62
62
  ## History
63
63
 
64
- * v0.2.0 - Support Rails 5 (Removed Rails 4.2 support)
64
+ * v0.2.1 - Added Rails 5.0.1 support (Removed Rails 5.0.0 support)
65
+ * v0.2.0 - Added Rails 5 support (Removed Rails 4.2 support)
65
66
  * v0.1.12 - Missing require
66
67
  * v0.1.11 - Explicit gem dependencies
67
68
  * v0.1.10 - Upgrade to schmea_plus_core 1.0
@@ -1,3 +1,3 @@
1
1
  eval File.read File.expand_path('../../Gemfile.base', __FILE__)
2
2
 
3
- gem "activerecord", "~> 5.0.0"
3
+ gem "activerecord", "~> 5.0.1"
@@ -3,7 +3,7 @@ module SchemaPlusPgIndexes
3
3
  module ConnectionAdapters
4
4
  module PostgresqlAdapter
5
5
  #
6
- # SchemaPlusPgIndexes allows the column_names paramter
6
+ # SchemaPlusPgIndexes allows the column_names parameter
7
7
  # to be left off
8
8
  #
9
9
  def add_index(table_name, column_names, options={})
@@ -8,19 +8,6 @@ module SchemaPlusPgIndexes
8
8
  def after(env)
9
9
  index_defs = env.connection.indexes(env.table.name)
10
10
 
11
- def set_index_options(name, options, index_defs)
12
- index_def = index_defs.find(&its.name == name)
13
- options[:case_sensitive] = false unless index_def.case_sensitive?
14
- options[:expression] = index_def.expression if index_def.expression and index_def.case_sensitive?
15
- unless index_def.operator_classes.blank?
16
- if index_def.columns.uniq.length <= 1 && index_def.operator_classes.values.uniq.length == 1
17
- options[:operator_class] = index_def.operator_classes.values.first
18
- else
19
- options[:operator_class] = index_def.operator_classes
20
- end
21
- end
22
- end
23
-
24
11
  env.table.columns.each do |column_dump|
25
12
  index = column_dump.options[:index]
26
13
  set_index_options(index[:name], index, index_defs) if index
@@ -31,6 +18,20 @@ module SchemaPlusPgIndexes
31
18
  end
32
19
  end
33
20
 
21
+ def set_index_options(name, options, index_defs)
22
+ index_def = index_defs.find(&its.name == name)
23
+ options[:case_sensitive] = false unless index_def.case_sensitive?
24
+ options[:expression] = index_def.expression if index_def.expression and index_def.case_sensitive?
25
+ unless index_def.operator_classes.blank?
26
+ if index_def.columns.uniq.length <= 1 && index_def.operator_classes.values.uniq.length == 1
27
+ options[:operator_class] = index_def.operator_classes.values.first
28
+ else
29
+ options[:operator_class] = index_def.operator_classes
30
+ end
31
+ end
32
+ end
33
+
34
+
34
35
  end
35
36
  end
36
37
  end
@@ -34,7 +34,7 @@ module SchemaPlusPgIndexes
34
34
  case_insensitive = (options.delete(:case_sensitive) == false)
35
35
 
36
36
  if expression
37
- raise ArgumentError, "Cannot specify :case_sensitive => false with an expression. Use LOWER(column_name)" if case_insensitive
37
+ raise ArgumentError, "Cannot specify :case_sensitive => false with an expression. Use LOWER(column_name)" if case_insensitive
38
38
  expression.strip!
39
39
  if m = expression.match(/^using\s+(?<using>\S+)\s*(?<rest>.*)/i)
40
40
  options[:using] = m[:using]
@@ -55,22 +55,23 @@ module SchemaPlusPgIndexes
55
55
  end
56
56
 
57
57
  if operator_classes or case_insensitive
58
- option_strings = Hash[column_names.map {|name| [name, '']}]
59
- (operator_classes||{}).stringify_keys.each do |column, opclass|
60
- option_strings[column] += " #{opclass}" if opclass and column.present?
61
- end
62
- option_strings = connection.send :add_index_sort_order, option_strings, column_names, options
63
-
64
58
  if case_insensitive
65
59
  caseable_columns = connection.columns(table_name).select { |col| [:string, :text].include?(col.type) }.map(&:name)
66
60
  quoted_column_names = column_names.map do |col_name|
67
- (caseable_columns.include?(col_name.to_s) ? "LOWER(#{connection.quote_column_name(col_name)})" : connection.quote_column_name(col_name)) + option_strings[col_name]
61
+ [col_name, (caseable_columns.include?(col_name.to_s) ?
62
+ "LOWER(#{connection.quote_column_name(col_name)})" : connection.quote_column_name(col_name))]
68
63
  end
64
+ quoted_columns = Hash[quoted_column_names]
69
65
  else
70
- quoted_column_names = column_names.map { |col_name| connection.quote_column_name(col_name) + option_strings[col_name] }
66
+ quoted_columns = Hash[column_names.map { |col_name| [col_name, connection.quote_column_name(col_name)] }]
67
+ end
68
+
69
+ (operator_classes||{}).stringify_keys.each do |column, opclass|
70
+ quoted_columns[column] += " #{opclass}" if opclass and column.present?
71
71
  end
72
+ quoted_columns = connection.send :add_index_sort_order, quoted_columns, **options
72
73
 
73
- env.sql.columns = quoted_column_names.join(', ')
74
+ env.sql.columns = quoted_columns.values.join(', ')
74
75
  end
75
76
 
76
77
  if expression
@@ -1,3 +1,3 @@
1
1
  module SchemaPlusPgIndexes
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
19
 
20
- gem.add_dependency "activerecord", "~> 5.0"
20
+ gem.add_dependency "activerecord", "~> 5.0", ">= 5.0.1"
21
21
  gem.add_dependency "schema_plus_indexes", "~> 0.2", ">= 0.2.4"
22
22
  gem.add_dependency "schema_plus_core", "~> 2.0"
23
23
  gem.add_dependency "its-it", "~> 1.2"
@@ -25,7 +25,7 @@ Gem::Specification.new do |gem|
25
25
  gem.add_development_dependency "bundler", "~> 1.7"
26
26
  gem.add_development_dependency "rake", "~> 10.0"
27
27
  gem.add_development_dependency "rspec", "~> 3.0.0"
28
- gem.add_development_dependency "schema_dev", "~> 3.6"
28
+ gem.add_development_dependency "schema_dev", "~> 3.8"
29
29
  gem.add_development_dependency "simplecov"
30
30
  gem.add_development_dependency "simplecov-gem-profile"
31
31
  end
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.2.0
4
+ version: 0.2.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: 2016-12-23 00:00:00.000000000 Z
11
+ date: 2017-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -17,6 +17,9 @@ dependencies:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '5.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 5.0.1
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -24,6 +27,9 @@ dependencies:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
29
  version: '5.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 5.0.1
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: schema_plus_indexes
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -120,14 +126,14 @@ dependencies:
120
126
  requirements:
121
127
  - - "~>"
122
128
  - !ruby/object:Gem::Version
123
- version: '3.6'
129
+ version: '3.8'
124
130
  type: :development
125
131
  prerelease: false
126
132
  version_requirements: !ruby/object:Gem::Requirement
127
133
  requirements:
128
134
  - - "~>"
129
135
  - !ruby/object:Gem::Version
130
- version: '3.6'
136
+ version: '3.8'
131
137
  - !ruby/object:Gem::Dependency
132
138
  name: simplecov
133
139
  requirement: !ruby/object:Gem::Requirement