directiverecord 0.1.20 → 0.1.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.rdoc +6 -0
- data/VERSION +1 -1
- data/lib/directive_record/query/big_query.rb +7 -5
- data/lib/directive_record/query/sql.rb +16 -5
- data/lib/directive_record/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MmYzMWQ2NTkwOWRkMWJhNTRhNDVjM2U5ODYzNTgwY2ZhZWU4YzkyMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Mzg2NmQzNmJjYmI0Y2ZhOGY1ODM1YTBhMmE3NjUzNjU5ZjBmZWU4Mw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MGRjNjBmNmQ5ZTJkNTVmMjUxMDk3MDM4ZTdlYWQ3MTY0YmY4OGI0Mzk3Y2Ix
|
10
|
+
MmZmY2MyYTI1ZTc0Mjc4MmQ2YjA3NWZhNmRiNTFlOGU2ZDk0NDk5NDJmYjA1
|
11
|
+
NmY5YmQwYTczNWM3MGY2MTI2ZTg4MzBiYTk4MDZmNDQ4NGVlZWY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDRjNjg0NmJhZjhkYmY0OTZmOTg1YjA3MjQ1YmQ5MDAzY2E0OTQ1OGZlYjRl
|
14
|
+
NzQzMDQ0MGVmNTRiNDE0NzIwNGRkYjUwMzljYjA4YTFkOWEyNjAxMWIyODhk
|
15
|
+
Mzc5YWY0MjBiMmVhYzVhNzMzMGVkMWMyYTVhY2JlZmJmMjk2MzI=
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
= DirectiveRecord CHANGELOG
|
2
2
|
|
3
|
+
== Version 0.1.21 (April 3, 2015)
|
4
|
+
|
5
|
+
* Storing original sql alias of a calculated column when numerizing aliases
|
6
|
+
* Updating SELECT statement when dealing with auto-aggregated field as a HAVING statement
|
7
|
+
* Corrected having multiple HAVING statements within a BigQuery query
|
8
|
+
|
3
9
|
== Version 0.1.20 (April 3, 2015)
|
4
10
|
|
5
11
|
* Improved HAVING statement detection
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.21
|
@@ -45,11 +45,13 @@ module DirectiveRecord
|
|
45
45
|
end
|
46
46
|
end if options[:group_by]
|
47
47
|
|
48
|
-
[:group_by, :
|
49
|
-
|
50
|
-
value =
|
51
|
-
|
52
|
-
|
48
|
+
{", " => [:group_by, :order_by], " AND " => [:having]}.each do |delimiter, keys|
|
49
|
+
keys.each do |key|
|
50
|
+
if value = options[key]
|
51
|
+
value = value.join delimiter
|
52
|
+
aliases.each{|pattern, replacement| value.gsub! pattern, replacement}
|
53
|
+
options[key] = value
|
54
|
+
end
|
53
55
|
end
|
54
56
|
end
|
55
57
|
end
|
@@ -150,16 +150,19 @@ SQL
|
|
150
150
|
sql = "ROUND(#{sql}, #{scale})"
|
151
151
|
sql_alias ||= quote_alias(path)
|
152
152
|
end
|
153
|
-
|
154
|
-
sql = sql.gsub(/ AS .*$/, "")
|
155
|
-
sql_alias = options[:aliases][prepend_base_alias(sql_alias || sql)] = "c#{array.size + 1}"
|
156
|
-
end
|
153
|
+
|
157
154
|
unless sql_alias
|
158
155
|
sql.match(/^(.*) AS (.*)$/)
|
159
156
|
sql = $1 if $1
|
160
157
|
sql_alias = $2
|
161
158
|
end
|
162
159
|
|
160
|
+
if options[:numerize_aliases]
|
161
|
+
c_alias = "c#{array.size + 1}"
|
162
|
+
options[:aggregated][sql_alias] = c_alias if !aggregate_method && sql_alias
|
163
|
+
sql_alias = options[:aliases][prepend_base_alias(sql_alias || sql)] = c_alias
|
164
|
+
end
|
165
|
+
|
163
166
|
sql.gsub!(/sub:(\w+)\./) { "#{quote_alias($1)}." } if sql.is_a?(String)
|
164
167
|
options[:aliases][sql] = sql_alias if sql_alias
|
165
168
|
|
@@ -242,7 +245,15 @@ SQL
|
|
242
245
|
.all? do |sql|
|
243
246
|
sql.match /(.*?)\s*(=|<=>|>=|>|<=|<|<>|!=|is|like|rlike|regexp|in|between|not|sounds|soundex)(\b|\s|$)/i
|
244
247
|
path = $1.strip
|
245
|
-
|
248
|
+
|
249
|
+
if (options[:aggregates] || {})[path]
|
250
|
+
normalize_select!(opts = options.deep_dup.merge(:select => [path]))
|
251
|
+
options[:select].concat(opts[:select]).uniq!
|
252
|
+
options[:aggregated].merge!(opts[:aggregated])
|
253
|
+
false
|
254
|
+
else
|
255
|
+
!(aliases[path] || path).match(/\b(count|sum|min|max|avg)\(/i)
|
256
|
+
end
|
246
257
|
end
|
247
258
|
end
|
248
259
|
|