pg_power 1.3.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown
CHANGED
@@ -16,6 +16,9 @@ ActiveRecord extension to get more from PostgreSQL:
|
|
16
16
|
|
17
17
|
It was tested with Rails 3.1.x and 3.2.x, Ruby 1.8.7 REE and 1.9.3.
|
18
18
|
|
19
|
+
NOTE: JRuby is not yet supported. The current ActiveRecord JDBC
|
20
|
+
adapter has its own Rails4-compatible method named "create_schema" which
|
21
|
+
conflicts with this gem.
|
19
22
|
|
20
23
|
## Schemas
|
21
24
|
|
@@ -3,7 +3,7 @@ module ActiveRecord
|
|
3
3
|
module SchemaStatements # :nodoc:
|
4
4
|
# Regexp used to find the function name and function argument of a
|
5
5
|
# function call
|
6
|
-
FUNCTIONAL_INDEX_REGEXP = /(\w+)\((\w+)\)/
|
6
|
+
FUNCTIONAL_INDEX_REGEXP = /(\w+)\(((?:'.+'(?:::\w+)?, *)*)(\w+)\)/
|
7
7
|
|
8
8
|
# Adds a new index to the table. +column_name+ can be a single Symbol, or
|
9
9
|
# an Array of Symbols.
|
@@ -149,7 +149,7 @@ module ActiveRecord
|
|
149
149
|
def quoted_columns_for_index(column_names, options = {})
|
150
150
|
column_names.map do |name|
|
151
151
|
if name =~ FUNCTIONAL_INDEX_REGEXP
|
152
|
-
"#{$1}(#{quote_column_name($
|
152
|
+
"#{$1}(#{$2}#{quote_column_name($3)})"
|
153
153
|
else
|
154
154
|
quote_column_name(name)
|
155
155
|
end
|
@@ -160,7 +160,7 @@ module ActiveRecord
|
|
160
160
|
# Map an expression to a name appropriate for an index
|
161
161
|
def expression_index_name(column_name)
|
162
162
|
if column_name =~ FUNCTIONAL_INDEX_REGEXP
|
163
|
-
"#{$1.downcase}_#{$
|
163
|
+
"#{$1.downcase}_#{$3}"
|
164
164
|
else
|
165
165
|
column_name
|
166
166
|
end
|
@@ -95,7 +95,7 @@ module ActiveRecord # :nodoc:
|
|
95
95
|
if column_names.empty?
|
96
96
|
definition = index[:definition].sub(INDEX_WHERE_EXPRESION, '')
|
97
97
|
if column_expression = definition.match(INDEX_COLUMN_EXPRESSION)[1]
|
98
|
-
column_names = column_expression
|
98
|
+
column_names = split_expression(column_expression).map do |functional_name|
|
99
99
|
remove_type(functional_name)
|
100
100
|
end
|
101
101
|
end
|
@@ -104,6 +104,33 @@ module ActiveRecord # :nodoc:
|
|
104
104
|
column_names
|
105
105
|
end
|
106
106
|
|
107
|
+
# Splits only on commas outside of parens
|
108
|
+
def split_expression(expression)
|
109
|
+
result = []
|
110
|
+
parens = 0
|
111
|
+
buffer = ""
|
112
|
+
|
113
|
+
expression.chars do |char|
|
114
|
+
case char
|
115
|
+
when ','
|
116
|
+
if parens == 0
|
117
|
+
result.push(buffer)
|
118
|
+
buffer = ""
|
119
|
+
next
|
120
|
+
end
|
121
|
+
when '('
|
122
|
+
parens += 1
|
123
|
+
when ')'
|
124
|
+
parens -= 1
|
125
|
+
end
|
126
|
+
|
127
|
+
buffer << char
|
128
|
+
end
|
129
|
+
|
130
|
+
result << buffer unless buffer.empty?
|
131
|
+
result
|
132
|
+
end
|
133
|
+
|
107
134
|
# Find where statement from index definition
|
108
135
|
#
|
109
136
|
# @param [Hash] index index attributes
|
data/lib/pg_power/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_power
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2013-
|
15
|
+
date: 2013-05-01 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: pg
|
@@ -190,7 +190,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
190
190
|
version: '0'
|
191
191
|
segments:
|
192
192
|
- 0
|
193
|
-
hash:
|
193
|
+
hash: 509296341304110115
|
194
194
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
195
195
|
none: false
|
196
196
|
requirements:
|
@@ -199,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
199
199
|
version: '0'
|
200
200
|
requirements: []
|
201
201
|
rubyforge_project:
|
202
|
-
rubygems_version: 1.8.
|
202
|
+
rubygems_version: 1.8.24
|
203
203
|
signing_key:
|
204
204
|
specification_version: 3
|
205
205
|
summary: ActiveRecord extensions for PostgreSQL.
|