Refactor SQL generation - remove excess whitespace (double spaces before where, join and order by) (#2065)

This commit is contained in:
Rob Bygrave
2020-10-07 21:28:33 +13:00
committed by GitHub
parent 694518db0a
commit de22b7bf27
42 changed files with 96 additions and 108 deletions
@@ -31,7 +31,7 @@ public class TestOneToOneOptionalRelationship extends BaseTestCase {
String sql = trimSql(loggedSql.get(0), 1);
Assert.assertTrue(sql.contains("select t0.id, t0.name"));
Assert.assertTrue(sql.contains(" from oto_account t0 left join oto_user t1 on t1.account_id = t0.id where t0.id = ?"));
Assert.assertTrue(sql.contains(" from oto_account t0 left join oto_user t1 on t1.account_id = t0.id where t0.id = ?"));
}
@@ -66,7 +66,7 @@ public class TestOneToOneOptionalRelationship extends BaseTestCase {
String sql = trimSql(loggedSql.get(0), 1);
Assert.assertTrue(sql.contains("select t0.id, t0.name"));
Assert.assertTrue(sql.contains(" from oto_account t0 left join oto_user t1 on t1.account_id = t0.id where t0.id = ?"));
Assert.assertTrue(sql.contains(" from oto_account t0 left join oto_user t1 on t1.account_id = t0.id where t0.id = ?"));
String lazyLoadSql = trimSql(loggedSql.get(1), 5);
Assert.assertTrue(lazyLoadSql.contains("select t0.id, t0.name, t0.version, t0.when_created, t0.when_modified, t0.account_id from oto_user t0 where t0.id = ?"));
@@ -104,6 +104,6 @@ public class TestOneToOneOptionalRelationship extends BaseTestCase {
String sql = trimSql(loggedSql.get(0), 1);
Assert.assertTrue(sql.contains("select t0.id, t0.name"));
Assert.assertTrue(sql.contains(" from oto_account t0 left join oto_user t1 on t1.account_id = t0.id where t0.id = ?"));
Assert.assertTrue(sql.contains(" from oto_account t0 left join oto_user t1 on t1.account_id = t0.id where t0.id = ?"));
}
}
@@ -46,7 +46,7 @@ public class TestOneToOnePrimaryKeyJoin extends BaseTestCase {
OtoPrime oneWith = queryWithFetch.findOne();
assertThat(oneWith).isNotNull();
assertThat(sqlOf(queryWithFetch, 10)).contains("select t0.pid, t0.name, t0.version, t1.eid, t1.extra, t1.version from oto_prime t0 join oto_prime_extra t1 on t1.eid = t0.pid where t0.pid = ?")
assertThat(sqlOf(queryWithFetch, 10)).contains("select t0.pid, t0.name, t0.version, t1.eid, t1.extra, t1.version from oto_prime t0 join oto_prime_extra t1 on t1.eid = t0.pid where t0.pid = ?")
.as("we join to oto_prime_extra");
assertThat(oneWith.getExtra().getExtra()).isEqualTo("e" + desc);
@@ -45,7 +45,7 @@ public class TestOneToOnePrimaryKeyJoinBidi extends BaseTestCase {
OtoUBPrime oneWith = queryWithFetch.findOne();
assertThat(oneWith).isNotNull();
assertThat(sqlOf(queryWithFetch, 10)).contains("select t0.pid, t0.name, t0.version, t1.eid, t1.extra, t1.version, t1.eid from oto_ubprime t0 left join oto_ubprime_extra t1 on t1.eid = t0.pid where t0.pid = ?")
assertThat(sqlOf(queryWithFetch, 10)).contains("select t0.pid, t0.name, t0.version, t1.eid, t1.extra, t1.version, t1.eid from oto_ubprime t0 left join oto_ubprime_extra t1 on t1.eid = t0.pid where t0.pid = ?")
.as("we join to oto_prime_extra");
assertThat(oneWith.getExtra().getExtra()).isEqualTo("v" + desc);
@@ -66,7 +66,7 @@ public class TestOneToOnePrimaryKeyJoinOptional extends BaseTestCase {
OtoUPrime oneWith = queryWithFetch.findOne();
assertThat(oneWith).isNotNull();
assertThat(sqlOf(queryWithFetch, 6)).contains("select t0.pid, t0.name, t0.version, t1.eid, t1.extra, t1.version from oto_uprime t0 left join oto_uprime_extra t1 on t1.eid = t0.pid where t0.pid = ?")
assertThat(sqlOf(queryWithFetch, 6)).contains("select t0.pid, t0.name, t0.version, t1.eid, t1.extra, t1.version from oto_uprime t0 left join oto_uprime_extra t1 on t1.eid = t0.pid where t0.pid = ?")
.as("we join to oto_prime_extra");