use of org.springframework.data.relational.core.sql.Table in project spring-data-jdbc by spring-projects.
the class OrderByClauseVisitorUnitTests method shouldRenderOrderByAlias.
// DATAJDBC-309
@Test
void shouldRenderOrderByAlias() {
Table employee = SQL.table("employee").as("emp");
Column column = employee.column("name").as("emp_name");
Select select = Select.builder().select(column).from(employee).orderBy(OrderByField.from(column).asc()).build();
OrderByClauseVisitor visitor = new OrderByClauseVisitor(new SimpleRenderContext(NamingStrategies.asIs()));
select.visit(visitor);
assertThat(visitor.getRenderedPart().toString()).isEqualTo("emp_name ASC");
}
use of org.springframework.data.relational.core.sql.Table in project spring-data-jdbc by spring-projects.
the class OrderByClauseVisitorUnitTests method shouldRenderOrderByFullyQualifiedName.
// GH-968
@Test
void shouldRenderOrderByFullyQualifiedName() {
Table employee = SQL.table("employee");
Column column = employee.column("name");
Select select = Select.builder().select(column).from(employee).orderBy(OrderByField.from(column).asc()).build();
OrderByClauseVisitor visitor = new OrderByClauseVisitor(new SimpleRenderContext(NamingStrategies.asIs()));
select.visit(visitor);
assertThat(visitor.getRenderedPart().toString()).isEqualTo("employee.name ASC");
}
use of org.springframework.data.relational.core.sql.Table in project spring-data-jdbc by spring-projects.
the class InsertRendererUnitTests method shouldRenderInsert.
// DATAJDBC-335
@Test
public void shouldRenderInsert() {
Table bar = SQL.table("bar");
Insert insert = Insert.builder().into(bar).values(SQL.bindMarker()).build();
assertThat(SqlRenderer.toString(insert)).isEqualTo("INSERT INTO bar VALUES (?)");
}
use of org.springframework.data.relational.core.sql.Table in project spring-data-jdbc by spring-projects.
the class UpdateRendererUnitTests method shouldRenderMultipleColumnUpdate.
// DATAJDBC-335
@Test
public void shouldRenderMultipleColumnUpdate() {
Table table = SQL.table("mytable");
Column foo = table.column("foo");
Column bar = table.column("bar");
Update update = //
StatementBuilder.update(table).set(foo.set(SQL.bindMarker()), //
bar.set(SQL.bindMarker())).build();
assertThat(SqlRenderer.toString(update)).isEqualTo("UPDATE mytable SET foo = ?, bar = ?");
}
use of org.springframework.data.relational.core.sql.Table in project spring-data-jdbc by spring-projects.
the class UpdateRendererUnitTests method shouldCreateUpdateWIthCondition.
// DATAJDBC-335
@Test
public void shouldCreateUpdateWIthCondition() {
Table table = SQL.table("mytable");
Column column = table.column("foo");
Update update = StatementBuilder.update(table).set(column.set(SQL.bindMarker())).where(column.isNull()).build();
assertThat(SqlRenderer.toString(update)).isEqualTo("UPDATE mytable SET foo = ? WHERE mytable.foo IS NULL");
}
Aggregations