cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From med...@apache.org
Subject svn commit: r787151 - /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerSelectTranslator.java
Date Mon, 22 Jun 2009 06:29:19 GMT
Author: medgar
Date: Mon Jun 22 06:29:19 2009
New Revision: 787151

URL: http://svn.apache.org/viewvc?rev=787151&view=rev
Log:
CAY-1244 - fix TOP fetch limit on DISTINCT selects

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerSelectTranslator.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerSelectTranslator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerSelectTranslator.java?rev=787151&r1=787150&r2=787151&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerSelectTranslator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerSelectTranslator.java
Mon Jun 22 06:29:19 2009
@@ -30,7 +30,15 @@
         int limit = metadata.getFetchLimit();
         
         if (limit > 0) {
-        	buffer.replace(0, 6, "SELECT TOP " + limit);
+        	String sql = buffer.toString();
+        	
+        	// If contains distinct insert top limit after
+        	if (sql.startsWith("SELECT DISTINCT ")) {
+        		buffer.replace(0, 15, "SELECT DISTINCT TOP " + limit);	
+        		
+        	} else {
+        		buffer.replace(0, 6, "SELECT TOP " + limit);	
+        	}
         }
     }
 



Mime
View raw message