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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc70bdc6154246ffdce6e0d4814560fef801f3e3
4
- data.tar.gz: 28798e0aac7a3130d121fac1d826182e73510340
3
+ metadata.gz: 4972f8c98aa0d771e6f66d7b969a7d17d3882b49
4
+ data.tar.gz: f320a5b19abc343d0ed9b71d078490d29c3d8b76
5
5
  SHA512:
6
- metadata.gz: d8d91f3ac15f35e23e9888a25d3a7519c9ccafe4bb5bc5ed2b0e5bd3d7df9778b98065d97e7a6b415b76465f953c30b0660ac8fd2ca94bcf21fccdee80b2452f
7
- data.tar.gz: c15c5467150524258c277507ef046a0ddd533f4e7dcaf3f834c199adc9571f2a8940629bfc7841f558c379a04fcab9abc2826500b5a135a2d39657a912c2c780
6
+ metadata.gz: 8c68d43a7a1328c44d0b064e1ee90d95334c70a816b7f1c6b75bb877743e75b20cbc8bde43352edc4623052184c8a93e3582b024363a362c02c9ba23694906b8
7
+ data.tar.gz: 7f2e85e313ba57b2e9d37a50c40dce288256348a7265ce3b164b3ee34a96bcb51299bc10a02eadde3e326be6338e535eae7aeadfc25ff7a7ccf28368418fd356
data/CHANGELOG.rdoc CHANGED
@@ -1,5 +1,9 @@
1
1
  = DirectiveRecord CHANGELOG
2
2
 
3
+ == Version 0.1.28 (August 13, 2015)
4
+
5
+ * Corrected handling HAVING statements for “virtual columns” defined in the GROUP BY
6
+
3
7
  == Version 0.1.27 (July 9, 2015)
4
8
 
5
9
  * Including extra join conditions
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.27
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
- !(aliases[path] || path).match(/\b(count|sum|min|max|avg)\(/i)
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
 
@@ -1,7 +1,7 @@
1
1
  module DirectiveRecord
2
2
  MAJOR = 0
3
3
  MINOR = 1
4
- TINY = 27
4
+ TINY = 28
5
5
 
6
6
  VERSION = [MAJOR, MINOR, TINY].join(".")
7
7
  end
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.27
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-07-09 00:00:00.000000000 Z
11
+ date: 2015-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord