directiverecord 0.1.27 → 0.1.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.rdoc +4 -0
- data/VERSION +1 -1
- data/lib/directive_record/query/sql.rb +27 -17
- data/lib/directive_record/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4972f8c98aa0d771e6f66d7b969a7d17d3882b49
|
4
|
+
data.tar.gz: f320a5b19abc343d0ed9b71d078490d29c3d8b76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c68d43a7a1328c44d0b064e1ee90d95334c70a816b7f1c6b75bb877743e75b20cbc8bde43352edc4623052184c8a93e3582b024363a362c02c9ba23694906b8
|
7
|
+
data.tar.gz: 7f2e85e313ba57b2e9d37a50c40dce288256348a7265ce3b164b3ee34a96bcb51299bc10a02eadde3e326be6338e535eae7aeadfc25ff7a7ccf28368418fd356
|
data/CHANGELOG.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.28
|
@@ -122,8 +122,8 @@ SQL
|
|
122
122
|
normalize_select!(options)
|
123
123
|
normalize_subselect!(options, original_options)
|
124
124
|
normalize_from!(options)
|
125
|
-
normalize_where!(options)
|
126
125
|
normalize_group_by!(options)
|
126
|
+
normalize_where!(options)
|
127
127
|
normalize_order_by!(options)
|
128
128
|
options.reject!{|k, v| v.blank?}
|
129
129
|
end
|
@@ -236,6 +236,28 @@ SQL
|
|
236
236
|
options[:from] = "#{base.table_name} #{base_alias}"
|
237
237
|
end
|
238
238
|
|
239
|
+
def normalize_group_by!(options)
|
240
|
+
normalize_select = false
|
241
|
+
|
242
|
+
options[:group_by].collect! do |x|
|
243
|
+
if x.match(/^(.*?) AS (\w+)$/)
|
244
|
+
if options[:select].any?{|x| x.include?("#{$1} AS ")}
|
245
|
+
$1
|
246
|
+
else
|
247
|
+
options[:select] << x
|
248
|
+
normalize_select = true
|
249
|
+
$2
|
250
|
+
end
|
251
|
+
else
|
252
|
+
x
|
253
|
+
end
|
254
|
+
end if options[:group_by]
|
255
|
+
|
256
|
+
if normalize_select
|
257
|
+
normalize_select!(options)
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
239
261
|
def normalize_where!(options)
|
240
262
|
regexp, aliases = /^\S+/, options[:aliases].invert
|
241
263
|
|
@@ -254,7 +276,10 @@ SQL
|
|
254
276
|
options[:aggregated].merge!(opts[:aggregated])
|
255
277
|
false
|
256
278
|
else
|
257
|
-
!(
|
279
|
+
!(
|
280
|
+
(aliases[path] || path).match(/\b(count|sum|min|max|avg)\(/i) ||
|
281
|
+
aliases.include?(path)
|
282
|
+
)
|
258
283
|
end
|
259
284
|
end
|
260
285
|
end
|
@@ -275,21 +300,6 @@ SQL
|
|
275
300
|
end
|
276
301
|
end
|
277
302
|
|
278
|
-
def normalize_group_by!(options)
|
279
|
-
options[:group_by].collect! do |x|
|
280
|
-
if x.match(/^(.*?) AS (\w+)$/)
|
281
|
-
if options[:select].any?{|x| x.include?("#{$1} AS ")}
|
282
|
-
$1
|
283
|
-
else
|
284
|
-
options[:select] << x
|
285
|
-
$2
|
286
|
-
end
|
287
|
-
else
|
288
|
-
x
|
289
|
-
end
|
290
|
-
end if options[:group_by]
|
291
|
-
end
|
292
|
-
|
293
303
|
def normalize_order_by!(options)
|
294
304
|
return unless options[:order_by]
|
295
305
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: directiverecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.28
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Engel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|