pg_saurus 3.2.1 → 3.2.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4147b6ee5df11ef09825b5c6b5d59d0521b357b
|
4
|
+
data.tar.gz: ee5a976b7fdd83f17492d3a877a11d4ebbc25a62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8689fb75e3adea700b5a1ced18232efccac99b3989370fbfbfe8ec3e9ef926f6bb97b8302fd0c59b22abfeeb01a716a521000c978fb6aa672a1517c5019402df
|
7
|
+
data.tar.gz: 23c7d58b7eeae4ad725c301cf54393eaccf36b1c7ac6ddbd3740846aafa54401e668c06bc5a2c01abd46ec67aefd55bfc8fa1e8019ff8980a7093ed0c83edfaa
|
@@ -5,9 +5,9 @@ module ActiveRecord # :nodoc:
|
|
5
5
|
# * indexes
|
6
6
|
class PostgreSQLAdapter
|
7
7
|
# Regex to find columns used in index statements
|
8
|
-
INDEX_COLUMN_EXPRESSION = /ON \w+(?: USING \w+ )?\((.+)\)/
|
8
|
+
INDEX_COLUMN_EXPRESSION = /ON [\w\.]+(?: USING \w+ )?\((.+)\)/
|
9
9
|
# Regex to find where clause in index statements
|
10
|
-
|
10
|
+
INDEX_WHERE_EXPRESSION = /WHERE (.+)$/
|
11
11
|
|
12
12
|
# Returns the list of all tables in the schema search path or a specified schema.
|
13
13
|
#
|
@@ -99,16 +99,24 @@ module ActiveRecord # :nodoc:
|
|
99
99
|
where = find_where_statement(index)
|
100
100
|
lengths = find_lengths(index)
|
101
101
|
|
102
|
-
PgSaurus::ConnectionAdapters::IndexDefinition.new(
|
102
|
+
PgSaurus::ConnectionAdapters::IndexDefinition.new(
|
103
|
+
table_name,
|
104
|
+
index[:name],
|
105
|
+
index[:unique],
|
106
|
+
column_names,
|
107
|
+
lengths,
|
108
|
+
where,
|
109
|
+
index[:access_method]
|
110
|
+
)
|
103
111
|
end
|
104
112
|
end.compact
|
105
113
|
end
|
106
114
|
|
107
|
-
# Find column names from index attributes. If the columns are virtual (
|
115
|
+
# Find column names from index attributes. If the columns are virtual (i.e.
|
108
116
|
# this is an expression index) then it will try to return the functions
|
109
|
-
# that represent each column
|
117
|
+
# that represent each column.
|
110
118
|
#
|
111
|
-
# @param [String] table_name the name of the table
|
119
|
+
# @param [String] table_name the name of the table, possibly schema-qualified
|
112
120
|
# @param [Hash] index index attributes
|
113
121
|
# @return [Array]
|
114
122
|
def find_column_names(table_name, index)
|
@@ -122,7 +130,7 @@ module ActiveRecord # :nodoc:
|
|
122
130
|
column_names = columns.values_at(*index[:keys]).compact
|
123
131
|
|
124
132
|
if column_names.empty?
|
125
|
-
definition = index[:definition].sub(
|
133
|
+
definition = index[:definition].sub(INDEX_WHERE_EXPRESSION, '')
|
126
134
|
if column_expression = definition.match(INDEX_COLUMN_EXPRESSION)[1]
|
127
135
|
column_names = split_expression(column_expression).map do |functional_name|
|
128
136
|
remove_type(functional_name)
|
@@ -165,7 +173,7 @@ module ActiveRecord # :nodoc:
|
|
165
173
|
# @param [Hash] index index attributes
|
166
174
|
# @return [String] where statement
|
167
175
|
def find_where_statement(index)
|
168
|
-
index[:definition].scan(
|
176
|
+
index[:definition].scan(INDEX_WHERE_EXPRESSION).flatten[0]
|
169
177
|
end
|
170
178
|
|
171
179
|
# Find length of index
|
data/lib/pg_saurus/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_saurus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Potapov Sergey
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2018-
|
16
|
+
date: 2018-04-24 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: pg
|