[Rt-commit] r4276 - in Jifty-DBI/trunk: . lib/Jifty/DBI/Handle

jesse at bestpractical.com jesse at bestpractical.com
Fri Dec 9 01:19:02 EST 2005


Author: jesse
Date: Fri Dec  9 01:19:01 2005
New Revision: 4276

Modified:
   Jifty-DBI/trunk/   (props changed)
   Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Informix.pm
Log:
 r19848 at truegrounds:  jesse | 2005-12-09 01:06:39 -0500
  * Ported fixes from SB to Informix handle


Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Informix.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Informix.pm	(original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Informix.pm	Fri Dec  9 01:19:01 2005
@@ -121,17 +121,26 @@
 
 =cut
 
-sub distinct_query {
-    my $self         = shift;
-    my $statementref = shift;
-    my $table        = shift;
-
-    # Wrapper select query in a subselect as Informix doesn't allow
-    # DISTINCT against CLOB/BLOB column types.
-    $$statementref
-        = "SELECT * FROM $table main WHERE id IN ( SELECT DISTINCT main.id FROM $$statementref )";
-
-}
+ sub distinct_query {
+     my $self = shift;
+     my $statementref = shift;
+    my $sb = shift;
+    my $table = $sb->table;
+ 
+    if ($sb->_order_clause =~ /(?<!main)\./) {
+        # Don't know how to do ORDER BY when the DISTINCT is in a subquery
+        warn "Query will contain duplicate rows; don't how how to ORDER BY across DISTINCT";
+       $$statementref = "SELECT main.* FROM $$statementref";
+    } else {
+        # Wrapper select query in a subselect as Informix doesn't allow
+        # DISTINCT against CLOB/BLOB column types.
+        $$statementref = "SELECT * FROM $table main WHERE id IN ( SELECT DISTINCT main.id FROM $$statementref )";
+    }
+    $$statementref .= $sb->_group_clause;
+    $$statementref .= $sb->_order_clause;
+ }
+ 
+ 
 
 1;
 


More information about the Rt-commit mailing list