use of org.springframework.data.relational.core.sql.Select in project spring-data-jdbc by spring-projects.
the class PostgresDialectRenderingUnitTests method shouldRenderSelectWithLimitWithLockRead.
// DATAJDBC-498
@Test
public void shouldRenderSelectWithLimitWithLockRead() {
Table table = Table.create("foo");
LockMode lockMode = LockMode.PESSIMISTIC_READ;
Select select = StatementBuilder.select(table.asterisk()).from(table).limit(10).lock(lockMode).build();
String sql = SqlRenderer.create(factory.createRenderContext()).render(select);
assertThat(sql).isEqualTo("SELECT foo.* FROM foo LIMIT 10 FOR SHARE OF foo");
}
use of org.springframework.data.relational.core.sql.Select in project spring-data-jdbc by spring-projects.
the class PostgresDialectRenderingUnitTests method shouldRenderSelectWithLimitOffset.
// DATAJDBC-278
@Test
public void shouldRenderSelectWithLimitOffset() {
Table table = Table.create("foo");
Select select = StatementBuilder.select(table.asterisk()).from(table).limit(10).offset(20).build();
String sql = SqlRenderer.create(factory.createRenderContext()).render(select);
assertThat(sql).isEqualTo("SELECT foo.* FROM foo LIMIT 10 OFFSET 20");
}
use of org.springframework.data.relational.core.sql.Select in project spring-data-jdbc by spring-projects.
the class PostgresDialectRenderingUnitTests method shouldRenderSelectWithLimitWithLockWrite.
// DATAJDBC-498
@Test
public void shouldRenderSelectWithLimitWithLockWrite() {
Table table = Table.create("foo");
LockMode lockMode = LockMode.PESSIMISTIC_WRITE;
Select select = StatementBuilder.select(table.asterisk()).from(table).limit(10).lock(lockMode).build();
String sql = SqlRenderer.create(factory.createRenderContext()).render(select);
assertThat(sql).isEqualTo("SELECT foo.* FROM foo LIMIT 10 FOR UPDATE OF foo");
}
use of org.springframework.data.relational.core.sql.Select in project spring-data-jdbc by spring-projects.
the class SqlServerDialectRenderingUnitTests method shouldApplyNamingStrategy.
// DATAJDBC-278
@Test
public void shouldApplyNamingStrategy() {
factory.setNamingStrategy(NamingStrategies.toUpper());
Table table = Table.create("foo");
Select select = StatementBuilder.select(table.asterisk()).from(table).build();
String sql = SqlRenderer.create(factory.createRenderContext()).render(select);
assertThat(sql).isEqualTo("SELECT FOO.* FROM FOO");
}
use of org.springframework.data.relational.core.sql.Select in project spring-data-jdbc by spring-projects.
the class SqlServerDialectRenderingUnitTests method shouldRenderSelectWithLimit.
// DATAJDBC-278
@Test
public void shouldRenderSelectWithLimit() {
Table table = Table.create("foo");
Select select = StatementBuilder.select(table.asterisk()).from(table).limit(10).build();
String sql = SqlRenderer.create(factory.createRenderContext()).render(select);
assertThat(sql).isEqualTo("SELECT foo.*, ROW_NUMBER() over (ORDER BY (SELECT 1)) AS __relational_row_number__ FROM foo ORDER BY __relational_row_number__ OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY");
}
Aggregations