From 413e6a9ce3b65ce20be78783779c35f442aa9b0d Mon Sep 17 00:00:00 2001
From: Alex Reisner <alex@alexreisner.com>
Date: Thu, 14 Oct 2010 22:36:27 -0400
Subject: [PATCH] Fix broken PostgreSQL compatibility.

Add a GROUP BY clause which yields correct SQL. (Incorrect query is
accepted by MySQL and SQLite but not PostgreSQL.)
---
 CHANGELOG.rdoc  | 5 +++--
 lib/geocoder.rb | 1 +
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG.rdoc b/CHANGELOG.rdoc
index 13445725..a1993133 100644
--- a/CHANGELOG.rdoc
+++ b/CHANGELOG.rdoc
@@ -4,9 +4,10 @@ Per-release changes to Geocoder.
 
 == 0.9.5 (TBA)
 
-* Don't allow :conditions hash in 'options' argument to 'nearbys' method (was deprecated in 0.9.3).
-* Separate Rails 2 and Rails 3-compatible branches.
+* Fix broken PostgreSQL compatibility (now 100% compatible).
 * Switch from Google's XML to JSON geocoding API.
+* Separate Rails 2 and Rails 3-compatible branches.
+* Don't allow :conditions hash in 'options' argument to 'nearbys' method (was deprecated in 0.9.3).
 
 == 0.9.4 (2010 Aug 2)
 
diff --git a/lib/geocoder.rb b/lib/geocoder.rb
index ecb2db92..d2e4eeef 100644
--- a/lib/geocoder.rb
+++ b/lib/geocoder.rb
@@ -111,6 +111,7 @@ module Geocoder
         ["#{lat_attr} BETWEEN ? AND ? AND #{lon_attr} BETWEEN ? AND ?"] +
         coordinate_bounds(latitude, longitude, radius)
       {
+        :group  => columns.map{ |c| c.name}.join(','),
         :order  => options[:order],
         :limit  => options[:limit],
         :offset => options[:offset],
-- 
GitLab