From cbf142857bfce52b0131ade69ce34880f813f2e7 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Fri, 26 Feb 2016 16:47:54 +0100 Subject: [PATCH] Replace SQL "count(*)" by "count(1)" It can have slight performance improvements on some databases. --- it/it-tests/src/test/java/it/dbCleaner/PurgeTest.java | 4 ++-- .../src/test/java/it/debt/TechnicalDebtPurgeTest.java | 4 ++-- .../projectAdministration/ProjectAdministrationTest.java | 2 +- .../main/java/org/sonar/db/property/PropertiesDao.java | 2 +- .../src/main/resources/org/sonar/db/ce/CeQueueMapper.xml | 6 +++--- .../org/sonar/db/component/ResourceKeyUpdaterMapper.xml | 2 +- .../resources/org/sonar/db/component/SnapshotMapper.xml | 2 +- .../org/sonar/db/loadedtemplate/LoadedTemplateMapper.xml | 2 +- .../org/sonar/db/measure/custom/CustomMeasureMapper.xml | 4 ++-- .../main/resources/org/sonar/db/metric/MetricMapper.xml | 2 +- .../org/sonar/db/notification/NotificationQueueMapper.xml | 2 +- .../org/sonar/db/permission/PermissionMapper.xml | 4 ++-- .../org/sonar/db/permission/PermissionTemplateMapper.xml | 6 +++--- .../src/main/resources/org/sonar/db/user/AuthorMapper.xml | 2 +- .../src/main/resources/org/sonar/db/user/GroupMapper.xml | 2 +- .../src/main/resources/org/sonar/db/user/RoleMapper.xml | 4 ++-- .../src/main/resources/org/sonar/db/user/UserMapper.xml | 2 +- sonar-db/src/test/java/org/sonar/db/DatabaseCommands.java | 2 +- sonar-db/src/test/java/org/sonar/db/DbTester.java | 2 +- .../java/org/sonar/db/component/ResourceIndexDaoTest.java | 6 +++--- .../src/test/java/org/sonar/db/purge/PurgeDaoTest.java | 8 ++++---- .../org/sonar/db/version/v50/FeedIssueLongDatesTest.java | 2 +- .../v51/CopyScmAccountsFromAuthorsToUsersTest.java | 4 ++-- .../db/version/v51/FeedAnalysisReportsLongDatesTest.java | 4 ++-- .../org/sonar/db/version/v51/FeedEventsLongDatesTest.java | 6 +++--- .../db/version/v51/FeedFileSourcesBinaryDataTest.java | 2 +- .../db/version/v51/FeedIssueChangesLongDatesTest.java | 4 ++-- .../org/sonar/db/version/v51/FeedIssuesLongDatesTest.java | 6 +++--- .../db/version/v51/FeedManualMeasuresLongDatesTest.java | 6 +++--- .../sonar/db/version/v51/FeedSnapshotsLongDatesTest.java | 6 +++--- .../org/sonar/db/version/v51/FeedUsersLongDatesTest.java | 2 +- .../InsertGateAdminPermissionForEachProfileAdminTest.java | 4 ++-- .../db/version/v54/RemoveComponentPagePropertiesTest.java | 2 +- .../db/version/v55/FeedRulesLongDateColumnsTest.java | 4 ++-- 34 files changed, 61 insertions(+), 61 deletions(-) diff --git a/it/it-tests/src/test/java/it/dbCleaner/PurgeTest.java b/it/it-tests/src/test/java/it/dbCleaner/PurgeTest.java index 430a2834d9f..936d17517cf 100644 --- a/it/it-tests/src/test/java/it/dbCleaner/PurgeTest.java +++ b/it/it-tests/src/test/java/it/dbCleaner/PurgeTest.java @@ -263,7 +263,7 @@ public class PurgeTest { } private int count(String condition) { - return orchestrator.getDatabase().countSql("select count(*) from " + condition); + return orchestrator.getDatabase().countSql("select count(1) from " + condition); } private void assertMeasuresCountForQualifier(String qualifier, int count) { @@ -275,7 +275,7 @@ public class PurgeTest { } private int countMeasures(String qualifier) { - String sql = "SELECT count(pm.id) FROM project_measures pm, snapshots s, metrics m where pm.snapshot_id=s.id and pm.metric_id=m.id and s.qualifier='" + qualifier + "'"; + String sql = "SELECT count(1) FROM project_measures pm, snapshots s, metrics m where pm.snapshot_id=s.id and pm.metric_id=m.id and s.qualifier='" + qualifier + "'"; return orchestrator.getDatabase().countSql(sql); } diff --git a/it/it-tests/src/test/java/it/debt/TechnicalDebtPurgeTest.java b/it/it-tests/src/test/java/it/debt/TechnicalDebtPurgeTest.java index c329e732b97..9ee0febd76e 100644 --- a/it/it-tests/src/test/java/it/debt/TechnicalDebtPurgeTest.java +++ b/it/it-tests/src/test/java/it/debt/TechnicalDebtPurgeTest.java @@ -33,8 +33,8 @@ import static util.ItUtils.projectDir; public class TechnicalDebtPurgeTest { - private static final String SQL_COUNT_MEASURES_ON_CHARACTERISTICS = "select count(*) from project_measures where characteristic_id is not null"; - private static final String SQL_COUNT_MEASURES_ON_DEBT_MEASURES_WITH_RULES = "select count(*) from project_measures where rule_id is not null and metric_id in (select id from metrics where name='sqale_index')"; + private static final String SQL_COUNT_MEASURES_ON_CHARACTERISTICS = "select count(1) from project_measures where characteristic_id is not null"; + private static final String SQL_COUNT_MEASURES_ON_DEBT_MEASURES_WITH_RULES = "select count(1) from project_measures where rule_id is not null and metric_id in (select id from metrics where name='sqale_index')"; @ClassRule public static Orchestrator orchestrator = Category2Suite.ORCHESTRATOR; diff --git a/it/it-tests/src/test/java/it/projectAdministration/ProjectAdministrationTest.java b/it/it-tests/src/test/java/it/projectAdministration/ProjectAdministrationTest.java index c9ebffb8ac9..885dbd7b5b1 100644 --- a/it/it-tests/src/test/java/it/projectAdministration/ProjectAdministrationTest.java +++ b/it/it-tests/src/test/java/it/projectAdministration/ProjectAdministrationTest.java @@ -247,7 +247,7 @@ public class ProjectAdministrationTest { } private int count(String condition) { - return orchestrator.getDatabase().countSql("select count(*) from " + condition); + return orchestrator.getDatabase().countSql("select count(1) from " + condition); } } 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 @@ 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 @@ 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 count(*) + SELECT count(1) FROM loaded_templates WHERE kee = #{key} AND template_type = #{type} 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 @@ 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 count(*) from notifications + select count(1) from notifications - 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 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 @@ 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 count(id) + SELECT count(1) FROM user_roles WHERE resource_id=#{id} 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 @@ 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); } } -- 2.39.5