|
21 | 21 |
|
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.Column; |
25 |
| -import org.springframework.data.relational.core.sql.Conditions; |
26 |
| -import org.springframework.data.relational.core.sql.Expressions; |
27 |
| -import org.springframework.data.relational.core.sql.Functions; |
28 |
| -import org.springframework.data.relational.core.sql.OrderByField; |
29 |
| -import org.springframework.data.relational.core.sql.SQL; |
30 |
| -import org.springframework.data.relational.core.sql.Select; |
31 |
| -import org.springframework.data.relational.core.sql.SqlIdentifier; |
32 |
| -import org.springframework.data.relational.core.sql.Table; |
| 24 | +import org.springframework.data.relational.core.sql.*; |
33 | 25 | import org.springframework.util.StringUtils;
|
34 | 26 |
|
35 | 27 | /**
|
@@ -349,4 +341,33 @@ public void shouldRenderWithRenderContext() {
|
349 | 341 | assertThat(rendered).isEqualTo(
|
350 | 342 | "SELECT COUNT(\"my_table\".*) AS counter, \"my_table\".\"reserved_keyword\" FROM \"my_table\" JOIN \"join_table\" ON \"my_table\".source = \"join_table\".target");
|
351 | 343 | }
|
| 344 | + |
| 345 | + |
| 346 | + @Test // GH-1034 |
| 347 | + void simpleComparisonWithStringArguments() { |
| 348 | + |
| 349 | + Table table_user = SQL.table("User"); |
| 350 | + Select select = StatementBuilder |
| 351 | + .select(table_user.column("name"),table_user.column("age")) |
| 352 | + .from(table_user) |
| 353 | + .where(Comparison.create("age",">",20)) |
| 354 | + .build(); |
| 355 | + |
| 356 | + final String rendered = SqlRenderer.toString(select); |
| 357 | + assertThat(rendered).isEqualTo("SELECT User.name, User.age FROM User WHERE age > 20"); |
| 358 | + } |
| 359 | + |
| 360 | + @Test // GH-1034 |
| 361 | + void simpleComparison() { |
| 362 | + |
| 363 | + Table table_user = SQL.table("User"); |
| 364 | + Select select = StatementBuilder |
| 365 | + .select(table_user.column("name"),table_user.column("age")) |
| 366 | + .from(table_user) |
| 367 | + .where(Comparison.create(table_user.column("age"),">",SQL.literalOf(20))) |
| 368 | + .build(); |
| 369 | + |
| 370 | + final String rendered = SqlRenderer.toString(select); |
| 371 | + assertThat(rendered).isEqualTo("SELECT User.name, User.age FROM User WHERE User.age > 20"); |
| 372 | + } |
352 | 373 | }
|
0 commit comments