use of org.springframework.data.relational.core.sql.Table in project spring-data-jdbc by spring-projects.
the class PostgresDialectRenderingUnitTests method shouldRenderSelectOrderByWithDirection.
// GH-821
@Test
void shouldRenderSelectOrderByWithDirection() {
Table table = Table.create("foo");
Select select = StatementBuilder.select(table.asterisk()).from(table).orderBy(OrderByField.from(Column.create("bar", table), Sort.Direction.ASC)).build();
String sql = SqlRenderer.create(factory.createRenderContext()).render(select);
assertThat(sql).isEqualTo("SELECT foo.* FROM foo ORDER BY foo.bar ASC");
}
use of org.springframework.data.relational.core.sql.Table in project spring-data-jdbc by spring-projects.
the class PostgresDialectRenderingUnitTests method shouldRenderSelectOrderByWithNullPrecedence.
// GH-821
@Test
void shouldRenderSelectOrderByWithNullPrecedence() {
Table table = Table.create("foo");
Select select = StatementBuilder.select(table.asterisk()).from(table).orderBy(OrderByField.from(Column.create("bar", table)).withNullHandling(Sort.NullHandling.NULLS_FIRST)).build();
String sql = SqlRenderer.create(factory.createRenderContext()).render(select);
assertThat(sql).isEqualTo("SELECT foo.* FROM foo ORDER BY foo.bar NULLS FIRST");
}
use of org.springframework.data.relational.core.sql.Table in project spring-data-jdbc by spring-projects.
the class PostgresDialectRenderingUnitTests method shouldRenderSelectOrderByWithDirectionAndNullHandling.
// GH-821
@Test
void shouldRenderSelectOrderByWithDirectionAndNullHandling() {
Table table = Table.create("foo");
Select select = StatementBuilder.select(table.asterisk()).from(table).orderBy(OrderByField.from(Column.create("bar", table), Sort.Direction.DESC).withNullHandling(Sort.NullHandling.NULLS_FIRST)).build();
String sql = SqlRenderer.create(factory.createRenderContext()).render(select);
assertThat(sql).isEqualTo("SELECT foo.* FROM foo ORDER BY foo.bar DESC NULLS FIRST");
}
use of org.springframework.data.relational.core.sql.Table in project spring-data-jdbc by spring-projects.
the class PostgresDialectRenderingUnitTests method shouldRenderSelectWithOffset.
// DATAJDBC-278
@Test
public void shouldRenderSelectWithOffset() {
Table table = Table.create("foo");
Select select = StatementBuilder.select(table.asterisk()).from(table).offset(10).build();
String sql = SqlRenderer.create(factory.createRenderContext()).render(select);
assertThat(sql).isEqualTo("SELECT foo.* FROM foo OFFSET 10");
}
use of org.springframework.data.relational.core.sql.Table in project spring-data-jdbc by spring-projects.
the class SqlServerDialectRenderingUnitTests method shouldRenderSelectWithLimitOffsetAndOrderByWithLockRead.
// DATAJDBC-498
@Test
public void shouldRenderSelectWithLimitOffsetAndOrderByWithLockRead() {
Table table = Table.create("foo");
LockMode lockMode = LockMode.PESSIMISTIC_READ;
Select select = StatementBuilder.select(table.asterisk()).from(table).orderBy(table.column("column_1")).limit(10).offset(20).lock(lockMode).build();
String sql = SqlRenderer.create(factory.createRenderContext()).render(select);
assertThat(sql).isEqualTo("SELECT foo.* FROM foo WITH (HOLDLOCK, ROWLOCK) ORDER BY foo.column_1 OFFSET 20 ROWS FETCH NEXT 10 ROWS ONLY");
}
Aggregations