|
21 | 21 | import org.junit.jupiter.api.Test;
|
22 | 22 | import org.springframework.data.relational.core.dialect.PostgresDialect;
|
23 | 23 | import org.springframework.data.relational.core.dialect.RenderContextFactory;
|
24 |
| -import org.springframework.data.relational.core.sql.*; |
| 24 | +import org.springframework.data.relational.core.sql.AnalyticFunction; |
| 25 | +import org.springframework.data.relational.core.sql.Column; |
| 26 | +import org.springframework.data.relational.core.sql.Comparison; |
| 27 | +import org.springframework.data.relational.core.sql.Conditions; |
| 28 | +import org.springframework.data.relational.core.sql.Expressions; |
| 29 | +import org.springframework.data.relational.core.sql.Functions; |
| 30 | +import org.springframework.data.relational.core.sql.InlineQuery; |
| 31 | +import org.springframework.data.relational.core.sql.LockMode; |
| 32 | +import org.springframework.data.relational.core.sql.OrderByField; |
| 33 | +import org.springframework.data.relational.core.sql.SQL; |
| 34 | +import org.springframework.data.relational.core.sql.Select; |
| 35 | +import org.springframework.data.relational.core.sql.SqlIdentifier; |
| 36 | +import org.springframework.data.relational.core.sql.StatementBuilder; |
| 37 | +import org.springframework.data.relational.core.sql.Table; |
25 | 38 | import org.springframework.util.StringUtils;
|
26 | 39 |
|
27 | 40 | /**
|
@@ -269,23 +282,24 @@ void shouldRenderJoinWithTwoInlineQueries() {
|
269 | 282 | Table department = SQL.table("department");
|
270 | 283 |
|
271 | 284 | Select innerSelectOne = Select.builder()
|
272 |
| - .select(employee.column("id"), employee.column("department_Id"), employee.column("name")).from(employee) |
| 285 | + .select(employee.column("id").as("empId"), employee.column("department_Id"), employee.column("name")) |
| 286 | + .from(employee) |
273 | 287 | .build();
|
274 | 288 | Select innerSelectTwo = Select.builder().select(department.column("id"), department.column("name")).from(department)
|
275 | 289 | .build();
|
276 | 290 |
|
277 | 291 | InlineQuery one = InlineQuery.create(innerSelectOne, "one");
|
278 | 292 | InlineQuery two = InlineQuery.create(innerSelectTwo, "two");
|
279 | 293 |
|
280 |
| - Select select = Select.builder().select(one.column("id"), two.column("name")).from(one) // |
281 |
| - .join(two).on(two.column("department_id")).equals(one.column("id")) // |
| 294 | + Select select = Select.builder().select(one.column("empId"), two.column("name")).from(one) // |
| 295 | + .join(two).on(two.column("department_id")).equals(one.column("empId")) // |
282 | 296 | .build();
|
283 | 297 |
|
284 | 298 | String sql = SqlRenderer.toString(select);
|
285 |
| - assertThat(sql).isEqualTo("SELECT one.id, two.name FROM (" // |
286 |
| - + "SELECT employee.id, employee.department_Id, employee.name FROM employee) one " // |
| 299 | + assertThat(sql).isEqualTo("SELECT one.empId, two.name FROM (" // |
| 300 | + + "SELECT employee.id AS empId, employee.department_Id, employee.name FROM employee) one " // |
287 | 301 | + "JOIN (SELECT department.id, department.name FROM department) two " //
|
288 |
| - + "ON two.department_id = one.id"); |
| 302 | + + "ON two.department_id = one.empId"); |
289 | 303 | }
|
290 | 304 |
|
291 | 305 | @Test // DATAJDBC-309
|
|
0 commit comments