]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4301 Fix sql query
authorJulien Lancelot <julien.lancelot@gmail.com>
Fri, 24 May 2013 13:38:34 +0000 (15:38 +0200)
committerJulien Lancelot <julien.lancelot@gmail.com>
Fri, 24 May 2013 13:38:34 +0000 (15:38 +0200)
sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml

index caa04f88709e9dd65709f1a85fd012c8d47a8ed8..6bcaf25261f67fd982e4312cca491921e80b5400 100644 (file)
     </where>
   </select>
 
-  <select id="selectIssueAndProjectIds" parameterType="map" resultType="Issue" fetchSize="2147483647">
-    select
-    <if test="_databaseId == 'mssql' ">
-      top #{maxResults}
-    </if>
-    i.id, i.project_id as projectId
+  <select id="selectIssueAndProjectIds" parameterType="map" resultType="Issue" fetchSize="1000000">
+    select i.id, i.project_id as projectId
+    <include refid="sortColumn"/>
+    <include refid="selectQueryConditions"/>
+    limit #{maxResults}
+  </select>
+
+  <!-- Oracle -->
+  <select id="selectIssueAndProjectIds" parameterType="map" resultType="Issue" fetchSize="1000000" databaseId="oracle">
+    select * from (
+      select i.id, i.project_id as projectId
+      <include refid="sortColumn"/>
+      <include refid="selectQueryConditions"/>
+    ) where rownum &lt;= #{maxResults}
+  </select>
+
+  <!-- SQL Server -->
+  <select id="selectIssueAndProjectIds" parameterType="map" resultType="Issue" fetchSize="1000000" databaseId="mssql">
+    select top #{maxResults} i.id, i.project_id as projectId
     <include refid="sortColumn"/>
     <include refid="selectQueryConditions"/>
   </select>
       <if test="query.createdBefore() != null">
         and i.issue_creation_date &lt; #{query.createdBefore}
       </if>
-      <if test="_databaseId == 'oracle' ">
-        and rownum &lt;= #{maxResults}
-      </if>
     </where>
-    order by i.id
-    <if test="_databaseId != 'oracle' and _databaseId != 'mssql'">
-      limit #{maxResults}
-    </if>
   </sql>
 
 </mapper>