querybuilder 0.5.3 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/History.txt +5 -0
  2. data/lib/QueryBuilder.rb +3 -2
  3. metadata +2 -2
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.5.4 2009-04-09
2
+
3
+ * 1 minor enhancement:
4
+ * Fixed a bug counting records wrong with multiple group fields
5
+
1
6
  == 0.5.3 2009-04-08
2
7
 
3
8
  * 1 minor enhancement:
data/lib/QueryBuilder.rb CHANGED
@@ -10,7 +10,7 @@ Syntax of a query is "RELATION [where ...|] [in ...|from SUB_QUERY|]".
10
10
  =end
11
11
  class QueryBuilder
12
12
  attr_reader :tables, :where, :errors, :join_tables, :distinct, :final_parser, :page_size
13
- VERSION = '0.5.3'
13
+ VERSION = '0.5.4'
14
14
 
15
15
  @@main_table = {}
16
16
  @@main_class = {}
@@ -653,7 +653,8 @@ class QueryBuilder
653
653
 
654
654
  if @group =~ /GROUP\s+BY\s+(.+)/
655
655
  # we need to COALESCE in order to count groups where $1 is NULL.
656
- count_on = "COUNT(DISTINCT COALESCE(#{$1},0))"
656
+ fields = $1.split(",").map{|f| "COALESCE(#{f.strip},0)"}.join(",")
657
+ count_on = "COUNT(DISTINCT #{fields})"
657
658
  elsif @distinct
658
659
  count_on = "COUNT(DISTINCT #{table}.id)"
659
660
  else
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: querybuilder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gaspard Bucher
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-08 00:00:00 +02:00
12
+ date: 2009-04-09 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency