aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2016-02-26 16:47:54 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2016-02-29 12:12:16 +0100
commitcbf142857bfce52b0131ade69ce34880f813f2e7 (patch)
tree2294fe7aa748c156662b12a3e3ce13ee35fd76dc /sonar-db
parentafe276c062e03d7c0ed7bab97b0ee8cf0511423e (diff)
downloadsonarqube-cbf142857bfce52b0131ade69ce34880f813f2e7.tar.gz
sonarqube-cbf142857bfce52b0131ade69ce34880f813f2e7.zip
Replace SQL "count(*)" by "count(1)"
It can have slight performance improvements on some databases.
Diffstat (limited to 'sonar-db')
-rw-r--r--sonar-db/src/main/java/org/sonar/db/property/PropertiesDao.java2
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/ce/CeQueueMapper.xml6
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/component/ResourceKeyUpdaterMapper.xml2
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/component/SnapshotMapper.xml2
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/loadedtemplate/LoadedTemplateMapper.xml2
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/measure/custom/CustomMeasureMapper.xml4
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/metric/MetricMapper.xml2
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/notification/NotificationQueueMapper.xml2
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/permission/PermissionMapper.xml4
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/permission/PermissionTemplateMapper.xml6
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/user/AuthorMapper.xml2
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/user/GroupMapper.xml2
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/user/RoleMapper.xml4
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/user/UserMapper.xml2
-rw-r--r--sonar-db/src/test/java/org/sonar/db/DatabaseCommands.java2
-rw-r--r--sonar-db/src/test/java/org/sonar/db/DbTester.java2
-rw-r--r--sonar-db/src/test/java/org/sonar/db/component/ResourceIndexDaoTest.java6
-rw-r--r--sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java8
-rw-r--r--sonar-db/src/test/java/org/sonar/db/version/v50/FeedIssueLongDatesTest.java2
-rw-r--r--sonar-db/src/test/java/org/sonar/db/version/v51/CopyScmAccountsFromAuthorsToUsersTest.java4
-rw-r--r--sonar-db/src/test/java/org/sonar/db/version/v51/FeedAnalysisReportsLongDatesTest.java4
-rw-r--r--sonar-db/src/test/java/org/sonar/db/version/v51/FeedEventsLongDatesTest.java6
-rw-r--r--sonar-db/src/test/java/org/sonar/db/version/v51/FeedFileSourcesBinaryDataTest.java2
-rw-r--r--sonar-db/src/test/java/org/sonar/db/version/v51/FeedIssueChangesLongDatesTest.java4
-rw-r--r--sonar-db/src/test/java/org/sonar/db/version/v51/FeedIssuesLongDatesTest.java6
-rw-r--r--sonar-db/src/test/java/org/sonar/db/version/v51/FeedManualMeasuresLongDatesTest.java6
-rw-r--r--sonar-db/src/test/java/org/sonar/db/version/v51/FeedSnapshotsLongDatesTest.java6
-rw-r--r--sonar-db/src/test/java/org/sonar/db/version/v51/FeedUsersLongDatesTest.java2
-rw-r--r--sonar-db/src/test/java/org/sonar/db/version/v54/InsertGateAdminPermissionForEachProfileAdminTest.java4
-rw-r--r--sonar-db/src/test/java/org/sonar/db/version/v54/RemoveComponentPagePropertiesTest.java2
-rw-r--r--sonar-db/src/test/java/org/sonar/db/version/v55/FeedRulesLongDateColumnsTest.java4
31 files changed, 56 insertions, 56 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/property/PropertiesDao.java b/sonar-db/src/main/java/org/sonar/db/property/PropertiesDao.java
index 5a14ef10891..111bf7ba8b0 100644
--- a/sonar-db/src/main/java/org/sonar/db/property/PropertiesDao.java
+++ b/sonar-db/src/main/java/org/sonar/db/property/PropertiesDao.java
@@ -79,7 +79,7 @@ public class PropertiesDao implements Dao {
Connection connection = session.getConnection();
PreparedStatement pstmt = null;
ResultSet rs = null;
- String sql = "SELECT count(*) FROM properties pp " +
+ String sql = "SELECT count(1) FROM properties pp " +
"left outer join projects pj on pp.resource_id = pj.id " +
"where pp.user_id is not null and (pp.resource_id is null or pj.uuid=?) " +
"and (" + DatabaseUtils.repeatCondition("pp.prop_key like ?", dispatcherKeys.size(), "or") + ")";
diff --git a/sonar-db/src/main/resources/org/sonar/db/ce/CeQueueMapper.xml b/sonar-db/src/main/resources/org/sonar/db/ce/CeQueueMapper.xml
index b8c4f5bf6ee..c9924353c1a 100644
--- a/sonar-db/src/main/resources/org/sonar/db/ce/CeQueueMapper.xml
+++ b/sonar-db/src/main/resources/org/sonar/db/ce/CeQueueMapper.xml
@@ -30,11 +30,11 @@
</select>
<select id="countByStatus" parameterType="org.sonar.db.ce.CeQueueDto$Status" resultType="int">
- select count(id) from ce_queue where status=#{status}
+ select count(1) from ce_queue where status=#{status}
</select>
<select id="countAll" resultType="int">
- select count(id) from ce_queue
+ select count(1) from ce_queue
</select>
<select id="selectByComponentUuid" parameterType="String" resultType="org.sonar.db.ce.CeQueueDto">
@@ -60,7 +60,7 @@
</select>
<select id="countByQuery" resultType="int">
- select count(id)
+ select count(1)
<include refid="sqlSelectByQuery"/>
</select>
diff --git a/sonar-db/src/main/resources/org/sonar/db/component/ResourceKeyUpdaterMapper.xml b/sonar-db/src/main/resources/org/sonar/db/component/ResourceKeyUpdaterMapper.xml
index 40add31c8cd..463b3c06a62 100644
--- a/sonar-db/src/main/resources/org/sonar/db/component/ResourceKeyUpdaterMapper.xml
+++ b/sonar-db/src/main/resources/org/sonar/db/component/ResourceKeyUpdaterMapper.xml
@@ -12,7 +12,7 @@
</resultMap>
<select id="countResourceByKey" parameterType="String" resultType="int">
- SELECT count(*)
+ SELECT count(1)
FROM projects
WHERE kee = #{key}
</select>
diff --git a/sonar-db/src/main/resources/org/sonar/db/component/SnapshotMapper.xml b/sonar-db/src/main/resources/org/sonar/db/component/SnapshotMapper.xml
index 1c408c558e2..8be7709f274 100644
--- a/sonar-db/src/main/resources/org/sonar/db/component/SnapshotMapper.xml
+++ b/sonar-db/src/main/resources/org/sonar/db/component/SnapshotMapper.xml
@@ -68,7 +68,7 @@
</select>
<select id="countLastSnapshotByComponentUuid" resultType="Integer">
- SELECT count(s.id)
+ SELECT count(1)
FROM snapshots s
INNER JOIN projects p ON p.id=s.project_id AND p.uuid=#{componentUuid}
<where>
diff --git a/sonar-db/src/main/resources/org/sonar/db/loadedtemplate/LoadedTemplateMapper.xml b/sonar-db/src/main/resources/org/sonar/db/loadedtemplate/LoadedTemplateMapper.xml
index 0395aad517a..09ba1c86d4c 100644
--- a/sonar-db/src/main/resources/org/sonar/db/loadedtemplate/LoadedTemplateMapper.xml
+++ b/sonar-db/src/main/resources/org/sonar/db/loadedtemplate/LoadedTemplateMapper.xml
@@ -10,7 +10,7 @@
</resultMap>
<select id="countByTypeAndKey" parameterType="map" resultType="int">
- SELECT count(*)
+ SELECT count(1)
FROM loaded_templates
WHERE kee = #{key} AND template_type = #{type}
</select>
diff --git a/sonar-db/src/main/resources/org/sonar/db/measure/custom/CustomMeasureMapper.xml b/sonar-db/src/main/resources/org/sonar/db/measure/custom/CustomMeasureMapper.xml
index 722724332f9..69cc9001983 100644
--- a/sonar-db/src/main/resources/org/sonar/db/measure/custom/CustomMeasureMapper.xml
+++ b/sonar-db/src/main/resources/org/sonar/db/measure/custom/CustomMeasureMapper.xml
@@ -80,13 +80,13 @@
</delete>
<select id="countByComponentUuid" resultType="Integer">
- select count(*)
+ select count(1)
from manual_measures m
where m.component_uuid=#{componentUuid}
</select>
<select id="countByComponentIdAndMetricId" resultType="Integer">
- select count(*)
+ select count(1)
from manual_measures m
where m.metric_id=#{metricId} and m.component_uuid=#{componentUuid}
</select>
diff --git a/sonar-db/src/main/resources/org/sonar/db/metric/MetricMapper.xml b/sonar-db/src/main/resources/org/sonar/db/metric/MetricMapper.xml
index 58518e16eb7..a1d2014533a 100644
--- a/sonar-db/src/main/resources/org/sonar/db/metric/MetricMapper.xml
+++ b/sonar-db/src/main/resources/org/sonar/db/metric/MetricMapper.xml
@@ -68,7 +68,7 @@
</select>
<select id="countEnabled" resultType="Integer">
- SELECT COUNT(*)
+ SELECT COUNT(1)
FROM metrics m
<where>
AND m.enabled=${_true}
diff --git a/sonar-db/src/main/resources/org/sonar/db/notification/NotificationQueueMapper.xml b/sonar-db/src/main/resources/org/sonar/db/notification/NotificationQueueMapper.xml
index c09eafc31d0..79c79dcdafb 100644
--- a/sonar-db/src/main/resources/org/sonar/db/notification/NotificationQueueMapper.xml
+++ b/sonar-db/src/main/resources/org/sonar/db/notification/NotificationQueueMapper.xml
@@ -14,7 +14,7 @@
</delete>
<select id="count" resultType="long">
- select count(*) from notifications
+ select count(1) from notifications
</select>
<select id="findOldest" parameterType="int" resultType="NotificationQueue">
diff --git a/sonar-db/src/main/resources/org/sonar/db/permission/PermissionMapper.xml b/sonar-db/src/main/resources/org/sonar/db/permission/PermissionMapper.xml
index df882e98a97..80630f5835f 100644
--- a/sonar-db/src/main/resources/org/sonar/db/permission/PermissionMapper.xml
+++ b/sonar-db/src/main/resources/org/sonar/db/permission/PermissionMapper.xml
@@ -57,7 +57,7 @@
<select id="groupsCountByProjectIdAndPermission" parameterType="map"
resultType="org.sonar.db.permission.CountByProjectAndPermissionDto">
- SELECT count(name) as count, permission, componentId
+ SELECT count(1) as count, permission, componentId
FROM
(SELECT g.name as name, group_role.role as permission, group_role.resource_id as componentId
FROM groups g
@@ -80,7 +80,7 @@
</select>
<select id="countGroups" parameterType="map" resultType="int">
- SELECT count(name)
+ SELECT count(1)
FROM
(SELECT g.name as name
FROM groups g
diff --git a/sonar-db/src/main/resources/org/sonar/db/permission/PermissionTemplateMapper.xml b/sonar-db/src/main/resources/org/sonar/db/permission/PermissionTemplateMapper.xml
index d0c515fc6c9..e7df62ba258 100644
--- a/sonar-db/src/main/resources/org/sonar/db/permission/PermissionTemplateMapper.xml
+++ b/sonar-db/src/main/resources/org/sonar/db/permission/PermissionTemplateMapper.xml
@@ -140,7 +140,7 @@
</select>
<select id="countGroups" parameterType="map" resultType="int">
- SELECT count(name) FROM
+ SELECT count(1) FROM
(SELECT g.name as name, g.description as description, ptg.permission_reference as permission
FROM groups g
LEFT JOIN perm_templates_groups ptg ON ptg.group_id=g.id
@@ -202,7 +202,7 @@
</select>
<select id="countAll" parameterType="String" resultType="int">
- SELECT count(id)
+ SELECT count(1)
FROM permission_templates
<where>
<if test="nameMatch!=null">
@@ -271,7 +271,7 @@
<select id="groupsCountByTemplateIdAndPermission" parameterType="map"
resultType="org.sonar.db.permission.CountByTemplateAndPermissionDto">
- SELECT count(name) as count, permission, templateId
+ SELECT count(1) as count, permission, templateId
FROM
(SELECT g.name as name, ptg.permission_reference as permission, ptg.template_id as templateId
FROM groups g
diff --git a/sonar-db/src/main/resources/org/sonar/db/user/AuthorMapper.xml b/sonar-db/src/main/resources/org/sonar/db/user/AuthorMapper.xml
index 440d2d74701..39e13226f0f 100644
--- a/sonar-db/src/main/resources/org/sonar/db/user/AuthorMapper.xml
+++ b/sonar-db/src/main/resources/org/sonar/db/user/AuthorMapper.xml
@@ -9,7 +9,7 @@
</select>
<select id="countDeveloperLogins" parameterType="long" resultType="int">
- SELECT count(id)
+ SELECT count(1)
FROM authors WHERE person_id=#{id}
</select>
diff --git a/sonar-db/src/main/resources/org/sonar/db/user/GroupMapper.xml b/sonar-db/src/main/resources/org/sonar/db/user/GroupMapper.xml
index d641c3b9b57..826828fcc9b 100644
--- a/sonar-db/src/main/resources/org/sonar/db/user/GroupMapper.xml
+++ b/sonar-db/src/main/resources/org/sonar/db/user/GroupMapper.xml
@@ -74,7 +74,7 @@
</select>
<select id="countByQuery" parameterType="map" resultType="int">
- SELECT count(g.id)
+ SELECT count(1)
FROM groups g
<where>
<if test="query!=null">
diff --git a/sonar-db/src/main/resources/org/sonar/db/user/RoleMapper.xml b/sonar-db/src/main/resources/org/sonar/db/user/RoleMapper.xml
index 86f44c53b55..f2c0c1c7207 100644
--- a/sonar-db/src/main/resources/org/sonar/db/user/RoleMapper.xml
+++ b/sonar-db/src/main/resources/org/sonar/db/user/RoleMapper.xml
@@ -103,12 +103,12 @@
</delete>
<select id="countResourceUserRoles" parameterType="long" resultType="int">
- SELECT count(id)
+ SELECT count(1)
FROM user_roles WHERE resource_id=#{id}
</select>
<select id="countResourceGroupRoles" parameterType="long" resultType="int">
- SELECT count(id)
+ SELECT count(1)
FROM group_roles WHERE resource_id=#{id}
</select>
diff --git a/sonar-db/src/main/resources/org/sonar/db/user/UserMapper.xml b/sonar-db/src/main/resources/org/sonar/db/user/UserMapper.xml
index 7b7deb1f711..bd16343959a 100644
--- a/sonar-db/src/main/resources/org/sonar/db/user/UserMapper.xml
+++ b/sonar-db/src/main/resources/org/sonar/db/user/UserMapper.xml
@@ -92,7 +92,7 @@
</select>
<select id="countByEmail" parameterType="String" resultType="long">
- SELECT count(u.id)
+ SELECT count(1)
FROM users u
where lower(u.email)=#{email} AND u.active=${_true}
</select>
diff --git a/sonar-db/src/test/java/org/sonar/db/DatabaseCommands.java b/sonar-db/src/test/java/org/sonar/db/DatabaseCommands.java
index b4c129d8af7..812ad84eb32 100644
--- a/sonar-db/src/test/java/org/sonar/db/DatabaseCommands.java
+++ b/sonar-db/src/test/java/org/sonar/db/DatabaseCommands.java
@@ -170,7 +170,7 @@ public abstract class DatabaseCommands {
Statement stmt = connection.createStatement();
ResultSet rs = null;
try {
- rs = stmt.executeQuery("select count(*) from " + table);
+ rs = stmt.executeQuery("select count(1) from " + table);
if (rs.next()) {
return rs.getInt(1) > 0;
}
diff --git a/sonar-db/src/test/java/org/sonar/db/DbTester.java b/sonar-db/src/test/java/org/sonar/db/DbTester.java
index 5e7531562e1..55ca750d3dc 100644
--- a/sonar-db/src/test/java/org/sonar/db/DbTester.java
+++ b/sonar-db/src/test/java/org/sonar/db/DbTester.java
@@ -144,7 +144,7 @@ public class DbTester extends ExternalResource {
*/
public int countRowsOfTable(String tableName) {
Preconditions.checkArgument(StringUtils.containsNone(tableName, " "), "Parameter must be the name of a table. Got " + tableName);
- return countSql("select count(*) from " + tableName);
+ return countSql("select count(1) from " + tableName);
}
/**
diff --git a/sonar-db/src/test/java/org/sonar/db/component/ResourceIndexDaoTest.java b/sonar-db/src/test/java/org/sonar/db/component/ResourceIndexDaoTest.java
index ef82c1813ac..9c393f0e67c 100644
--- a/sonar-db/src/test/java/org/sonar/db/component/ResourceIndexDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/component/ResourceIndexDaoTest.java
@@ -86,11 +86,11 @@ public class ResourceIndexDaoTest {
dao.indexProject(1);
// project
- assertThat(dbTester.countSql("select count(resource_id) from resource_index where resource_id=1")).isGreaterThan(0);
+ assertThat(dbTester.countSql("select count(1) from resource_index where resource_id=1")).isGreaterThan(0);
// directory
- assertThat(dbTester.countSql("select count(resource_id) from resource_index where resource_id=2")).isEqualTo(0);
+ assertThat(dbTester.countSql("select count(1) from resource_index where resource_id=2")).isEqualTo(0);
// file
- assertThat(dbTester.countSql("select count(resource_id) from resource_index where resource_id=3")).isGreaterThan(0);
+ assertThat(dbTester.countSql("select count(1) from resource_index where resource_id=3")).isGreaterThan(0);
}
@Test
diff --git a/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java b/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java
index ce61889688b..5c7192d66ee 100644
--- a/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java
@@ -148,7 +148,7 @@ public class PurgeDaoTest {
underTest.deleteProject(dbSession, "A");
dbSession.commit();
- assertThat(dbTester.countSql("select count(id) from projects where uuid='A'")).isZero();
+ assertThat(dbTester.countSql("select count(1) from projects where uuid='A'")).isZero();
assertThat(dbTester.countRowsOfTable("projects")).isZero();
}
@@ -159,17 +159,17 @@ public class PurgeDaoTest {
// technical project
underTest.deleteProject(dbSession, "D");
dbSession.commit();
- assertThat(dbTester.countSql("select count(id) from projects where uuid='D'")).isZero();
+ assertThat(dbTester.countSql("select count(1) from projects where uuid='D'")).isZero();
// sub view
underTest.deleteProject(dbSession, "B");
dbSession.commit();
- assertThat(dbTester.countSql("select count(id) from projects where uuid='B'")).isZero();
+ assertThat(dbTester.countSql("select count(1) from projects where uuid='B'")).isZero();
// view
underTest.deleteProject(dbSession, "A");
dbSession.commit();
- assertThat(dbTester.countSql("select count(id) from projects where uuid='A'")).isZero();
+ assertThat(dbTester.countSql("select count(1) from projects where uuid='A'")).isZero();
}
@Test
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v50/FeedIssueLongDatesTest.java b/sonar-db/src/test/java/org/sonar/db/version/v50/FeedIssueLongDatesTest.java
index 2c009e825f8..2c64d884f62 100644
--- a/sonar-db/src/test/java/org/sonar/db/version/v50/FeedIssueLongDatesTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/version/v50/FeedIssueLongDatesTest.java
@@ -43,7 +43,7 @@ public class FeedIssueLongDatesTest {
MigrationStep migration = new FeedIssueLongDates(db.database(), system);
migration.execute();
- int count = db.countSql("select count(*) from issues where created_at_ms is not null and updated_at_ms is not null");
+ int count = db.countSql("select count(1) from issues where created_at_ms is not null and updated_at_ms is not null");
assertThat(count).isEqualTo(3);
}
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v51/CopyScmAccountsFromAuthorsToUsersTest.java b/sonar-db/src/test/java/org/sonar/db/version/v51/CopyScmAccountsFromAuthorsToUsersTest.java
index 2d6f8405ab8..43769596e1c 100644
--- a/sonar-db/src/test/java/org/sonar/db/version/v51/CopyScmAccountsFromAuthorsToUsersTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/version/v51/CopyScmAccountsFromAuthorsToUsersTest.java
@@ -80,8 +80,8 @@ public class CopyScmAccountsFromAuthorsToUsersTest {
migration.execute();
- assertThat(db.countSql("SELECT count(*) FROM USERS WHERE updated_at=" + updatedDate)).isEqualTo(0);
- assertThat(db.countSql("SELECT count(*) FROM USERS WHERE updated_at=" + oldDate)).isEqualTo(7);
+ assertThat(db.countSql("SELECT count(1) FROM USERS WHERE updated_at=" + updatedDate)).isEqualTo(0);
+ assertThat(db.countSql("SELECT count(1) FROM USERS WHERE updated_at=" + oldDate)).isEqualTo(7);
}
private User getUserByLogin(String login) {
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v51/FeedAnalysisReportsLongDatesTest.java b/sonar-db/src/test/java/org/sonar/db/version/v51/FeedAnalysisReportsLongDatesTest.java
index 2d9e13d0058..2900b8b35c1 100644
--- a/sonar-db/src/test/java/org/sonar/db/version/v51/FeedAnalysisReportsLongDatesTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/version/v51/FeedAnalysisReportsLongDatesTest.java
@@ -42,11 +42,11 @@ public class FeedAnalysisReportsLongDatesTest {
MigrationStep migration = new FeedAnalysisReportsLongDates(db.database(), system);
migration.execute();
- int count = db.countSql("select count(*) from analysis_reports where created_at_ms is not null and updated_at_ms is not null");
+ int count = db.countSql("select count(1) from analysis_reports where created_at_ms is not null and updated_at_ms is not null");
assertThat(count).isEqualTo(3);
int countWithAllDateFieldsNull = db
- .countSql("select count(*) from analysis_reports where created_at_ms is not null and updated_at_ms is not null and started_at_ms is not null and finished_at_ms is not null");
+ .countSql("select count(1) from analysis_reports where created_at_ms is not null and updated_at_ms is not null and started_at_ms is not null and finished_at_ms is not null");
assertThat(countWithAllDateFieldsNull).isEqualTo(2);
}
}
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v51/FeedEventsLongDatesTest.java b/sonar-db/src/test/java/org/sonar/db/version/v51/FeedEventsLongDatesTest.java
index 26e766a33dd..fee3a503ce8 100644
--- a/sonar-db/src/test/java/org/sonar/db/version/v51/FeedEventsLongDatesTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/version/v51/FeedEventsLongDatesTest.java
@@ -47,7 +47,7 @@ public class FeedEventsLongDatesTest {
migration.execute();
int count = db
- .countSql("select count(*) from events where " +
+ .countSql("select count(1) from events where " +
"created_at_ms is not null " +
"and event_date_ms is not null");
assertThat(count).isEqualTo(3);
@@ -63,7 +63,7 @@ public class FeedEventsLongDatesTest {
migration.execute();
int count = db
- .countSql("select count(*) from events where " +
+ .countSql("select count(1) from events where " +
"created_at_ms = 1234");
assertThat(count).isEqualTo(2);
}
@@ -76,7 +76,7 @@ public class FeedEventsLongDatesTest {
long time = parseDate("2014-09-25").getTime();
int count = db
- .countSql("select count(*) from events where " +
+ .countSql("select count(1) from events where " +
"created_at_ms=" + time);
assertThat(count).isEqualTo(1);
}
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v51/FeedFileSourcesBinaryDataTest.java b/sonar-db/src/test/java/org/sonar/db/version/v51/FeedFileSourcesBinaryDataTest.java
index 65458da7acd..a3a93e51ca3 100644
--- a/sonar-db/src/test/java/org/sonar/db/version/v51/FeedFileSourcesBinaryDataTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/version/v51/FeedFileSourcesBinaryDataTest.java
@@ -51,7 +51,7 @@ public class FeedFileSourcesBinaryDataTest {
MigrationStep migration = new FeedFileSourcesBinaryData(db.database());
migration.execute();
- int count = db.countSql("select count(*) from file_sources where binary_data is not null");
+ int count = db.countSql("select count(1) from file_sources where binary_data is not null");
assertThat(count).isEqualTo(3);
try (Connection connection = db.openConnection()) {
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v51/FeedIssueChangesLongDatesTest.java b/sonar-db/src/test/java/org/sonar/db/version/v51/FeedIssueChangesLongDatesTest.java
index 5abccafdd7b..ee1e6dbae4c 100644
--- a/sonar-db/src/test/java/org/sonar/db/version/v51/FeedIssueChangesLongDatesTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/version/v51/FeedIssueChangesLongDatesTest.java
@@ -42,11 +42,11 @@ public class FeedIssueChangesLongDatesTest {
MigrationStep migration = new FeedIssueChangesLongDates(db.database(), system);
migration.execute();
- int count = db.countSql("select count(*) from issue_changes where created_at_ms is not null and updated_at_ms is not null");
+ int count = db.countSql("select count(1) from issue_changes where created_at_ms is not null and updated_at_ms is not null");
assertThat(count).isEqualTo(3);
int countWithAllDateFieldsNull = db
- .countSql("select count(*) from issue_changes where created_at_ms is not null and updated_at_ms is not null and issue_change_creation_date_ms is not null");
+ .countSql("select count(1) from issue_changes where created_at_ms is not null and updated_at_ms is not null and issue_change_creation_date_ms is not null");
assertThat(countWithAllDateFieldsNull).isEqualTo(2);
}
}
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v51/FeedIssuesLongDatesTest.java b/sonar-db/src/test/java/org/sonar/db/version/v51/FeedIssuesLongDatesTest.java
index be15120aa82..123c3727512 100644
--- a/sonar-db/src/test/java/org/sonar/db/version/v51/FeedIssuesLongDatesTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/version/v51/FeedIssuesLongDatesTest.java
@@ -42,7 +42,7 @@ public class FeedIssuesLongDatesTest {
migration.execute();
int count = db
- .countSql("select count(*) from issues where " +
+ .countSql("select count(1) from issues where " +
"issue_creation_date_ms is not null " +
"and issue_update_date_ms is not null " +
"and issue_close_date_ms is not null");
@@ -59,7 +59,7 @@ public class FeedIssuesLongDatesTest {
migration.execute();
int count = db
- .countSql("select count(*) from issues where " +
+ .countSql("select count(1) from issues where " +
"issue_creation_date_ms = 0");
assertThat(count).isEqualTo(1);
}
@@ -73,7 +73,7 @@ public class FeedIssuesLongDatesTest {
migration.execute();
int count = db
- .countSql("select count(*) from issues where " +
+ .countSql("select count(1) from issues where " +
"issue_creation_date_ms=" + snapshotTime);
assertThat(count).isEqualTo(1);
}
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v51/FeedManualMeasuresLongDatesTest.java b/sonar-db/src/test/java/org/sonar/db/version/v51/FeedManualMeasuresLongDatesTest.java
index 12da57dd9c1..32498793fb1 100644
--- a/sonar-db/src/test/java/org/sonar/db/version/v51/FeedManualMeasuresLongDatesTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/version/v51/FeedManualMeasuresLongDatesTest.java
@@ -47,7 +47,7 @@ public class FeedManualMeasuresLongDatesTest {
migration.execute();
int count = db
- .countSql("select count(*) from manual_measures where " +
+ .countSql("select count(1) from manual_measures where " +
"created_at_ms is not null " +
"and updated_at_ms is not null");
assertThat(count).isEqualTo(2);
@@ -63,7 +63,7 @@ public class FeedManualMeasuresLongDatesTest {
migration.execute();
int count = db
- .countSql("select count(*) from manual_measures where " +
+ .countSql("select count(1) from manual_measures where " +
"created_at_ms = 1234");
assertThat(count).isEqualTo(1);
}
@@ -76,7 +76,7 @@ public class FeedManualMeasuresLongDatesTest {
long snapshotTime = parseDate("2014-09-25").getTime();
int count = db
- .countSql("select count(*) from manual_measures where " +
+ .countSql("select count(1) from manual_measures where " +
"created_at_ms=" + snapshotTime);
assertThat(count).isEqualTo(1);
}
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v51/FeedSnapshotsLongDatesTest.java b/sonar-db/src/test/java/org/sonar/db/version/v51/FeedSnapshotsLongDatesTest.java
index 1d414459270..6cdab7d90bd 100644
--- a/sonar-db/src/test/java/org/sonar/db/version/v51/FeedSnapshotsLongDatesTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/version/v51/FeedSnapshotsLongDatesTest.java
@@ -42,7 +42,7 @@ public class FeedSnapshotsLongDatesTest {
migration.execute();
int count = db
- .countSql("select count(*) from snapshots where created_at_ms is not null " +
+ .countSql("select count(1) from snapshots where created_at_ms is not null " +
"and build_date_ms is not null " +
"and period1_date_ms is not null " +
"and period2_date_ms is not null " +
@@ -62,7 +62,7 @@ public class FeedSnapshotsLongDatesTest {
migration.execute();
int count = db
- .countSql("select count(*) from snapshots where " +
+ .countSql("select count(1) from snapshots where " +
"created_at_ms = 0");
assertThat(count).isEqualTo(1);
}
@@ -76,7 +76,7 @@ public class FeedSnapshotsLongDatesTest {
migration.execute();
int count = db
- .countSql("select count(*) from snapshots where " +
+ .countSql("select count(1) from snapshots where " +
"created_at_ms=" + snapshotTime);
assertThat(count).isEqualTo(1);
}
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v51/FeedUsersLongDatesTest.java b/sonar-db/src/test/java/org/sonar/db/version/v51/FeedUsersLongDatesTest.java
index 556e00a271b..00d63a37f59 100644
--- a/sonar-db/src/test/java/org/sonar/db/version/v51/FeedUsersLongDatesTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/version/v51/FeedUsersLongDatesTest.java
@@ -43,7 +43,7 @@ public class FeedUsersLongDatesTest {
MigrationStep migration = new FeedUsersLongDates(db.database(), system);
migration.execute();
- int count = db.countSql("select count(*) from users where created_at_ms is not null and updated_at_ms is not null");
+ int count = db.countSql("select count(1) from users where created_at_ms is not null and updated_at_ms is not null");
assertThat(count).isEqualTo(3);
}
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v54/InsertGateAdminPermissionForEachProfileAdminTest.java b/sonar-db/src/test/java/org/sonar/db/version/v54/InsertGateAdminPermissionForEachProfileAdminTest.java
index 5e099a5f89f..8afdbdf09ab 100644
--- a/sonar-db/src/test/java/org/sonar/db/version/v54/InsertGateAdminPermissionForEachProfileAdminTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/version/v54/InsertGateAdminPermissionForEachProfileAdminTest.java
@@ -230,7 +230,7 @@ public class InsertGateAdminPermissionForEachProfileAdminTest {
private static String groupRoleRowSql(@Nullable Integer groupId, @Nullable Integer resourceId, String role) {
return format(
- "select count(*) from group_roles where group_id %s and resource_id %s and role = '%s'",
+ "select count(1) from group_roles where group_id %s and resource_id %s and role = '%s'",
whereClauseFromInteger(groupId),
whereClauseFromInteger(resourceId),
role);
@@ -248,7 +248,7 @@ public class InsertGateAdminPermissionForEachProfileAdminTest {
private static String userRoleRowSql(@Nullable Integer userId, @Nullable Integer resourceId, String role) {
return format(
- "select count(*) from user_roles where user_id %s and resource_id %s and role = '%s'",
+ "select count(1) from user_roles where user_id %s and resource_id %s and role = '%s'",
whereClauseFromInteger(userId),
whereClauseFromInteger(resourceId),
role);
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v54/RemoveComponentPagePropertiesTest.java b/sonar-db/src/test/java/org/sonar/db/version/v54/RemoveComponentPagePropertiesTest.java
index 5c0c2eec331..8533751c82f 100644
--- a/sonar-db/src/test/java/org/sonar/db/version/v54/RemoveComponentPagePropertiesTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/version/v54/RemoveComponentPagePropertiesTest.java
@@ -116,7 +116,7 @@ public class RemoveComponentPagePropertiesTest {
private static String propertiesRowSql(String key, @Nullable Integer resourceId, @Nullable Integer userId) {
return format(
- "select count(*) from properties where prop_key='%s' and resource_id %s and user_id %s and text_value = '%s'",
+ "select count(1) from properties where prop_key='%s' and resource_id %s and user_id %s and text_value = '%s'",
key,
whereClauseOfInteger(resourceId),
whereClauseOfInteger(userId),
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v55/FeedRulesLongDateColumnsTest.java b/sonar-db/src/test/java/org/sonar/db/version/v55/FeedRulesLongDateColumnsTest.java
index 240c0e79345..ff33afa7152 100644
--- a/sonar-db/src/test/java/org/sonar/db/version/v55/FeedRulesLongDateColumnsTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/version/v55/FeedRulesLongDateColumnsTest.java
@@ -52,9 +52,9 @@ public class FeedRulesLongDateColumnsTest {
underTest.execute();
- assertThat(db.countSql("select count(*) from rules where created_at_ms is not null and updated_at_ms is not null")).isEqualTo(3);
+ assertThat(db.countSql("select count(1) from rules where created_at_ms is not null and updated_at_ms is not null")).isEqualTo(3);
// Only 1 rules not updated
- assertThat(db.countSql("select count(*) from rules where created_at_ms='1000000000000' and updated_at_ms='1000000000000'")).isEqualTo(1);
+ assertThat(db.countSql("select count(1) from rules where created_at_ms='1000000000000' and updated_at_ms='1000000000000'")).isEqualTo(1);
}
}