Use fully qualified names in ORDER BY clause.

Closes #680
This commit is contained in:
Mark Paluch
2021-11-08 10:25:26 +01:00
parent 0ad751ec5c
commit c8ef7b4076
3 changed files with 8 additions and 5 deletions

View File

@@ -155,7 +155,7 @@ public class R2dbcEntityTemplateUnitTests {
StatementRecorder.RecordedStatement statement = recorder.getCreatedStatement(s -> s.startsWith("SELECT"));
assertThat(statement.getSql())
.isEqualTo("SELECT person.* FROM person WHERE person.THE_NAME = $1 ORDER BY THE_NAME ASC");
.isEqualTo("SELECT person.* FROM person WHERE person.THE_NAME = $1 ORDER BY person.THE_NAME ASC");
assertThat(statement.getBindings()).hasSize(1).containsEntry(0, Parameter.from("Walter"));
}
@@ -196,7 +196,7 @@ public class R2dbcEntityTemplateUnitTests {
StatementRecorder.RecordedStatement statement = recorder.getCreatedStatement(s -> s.startsWith("SELECT"));
assertThat(statement.getSql())
.isEqualTo("SELECT person.* FROM person WHERE person.THE_NAME = $1 ORDER BY THE_NAME ASC LIMIT 2");
.isEqualTo("SELECT person.* FROM person WHERE person.THE_NAME = $1 ORDER BY person.THE_NAME ASC LIMIT 2");
assertThat(statement.getBindings()).hasSize(1).containsEntry(0, Parameter.from("Walter"));
}

View File

@@ -77,6 +77,7 @@ class StatementMapperUnitTests {
PreparedOperation<?> preparedOperation = mapper.getMappedObject(selectSpec);
assertThat(preparedOperation.toQuery()).isEqualTo("SELECT table.* FROM table ORDER BY id DESC LIMIT 2 OFFSET 2");
assertThat(preparedOperation.toQuery())
.isEqualTo("SELECT table.* FROM table ORDER BY table.id DESC LIMIT 2 OFFSET 2");
}
}

View File

@@ -430,7 +430,8 @@ class PartTreeR2dbcQueryUnitTests {
PreparedOperation<?> preparedOperation = createQuery(r2dbcQuery, accessor);
assertThat(preparedOperation.get())
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age = $1 ORDER BY last_name DESC");
.isEqualTo(
"SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age = $1 ORDER BY users.last_name DESC");
}
@Test // gh-282
@@ -442,7 +443,8 @@ class PartTreeR2dbcQueryUnitTests {
PreparedOperation<?> preparedOperation = createQuery(r2dbcQuery, accessor);
assertThat(preparedOperation.get())
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age = $1 ORDER BY last_name ASC");
.isEqualTo(
"SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age = $1 ORDER BY users.last_name ASC");
}
@Test // gh-282