use of org.springframework.data.relational.core.sql.Column in project spring-data-jdbc by spring-projects.
the class OrderByClauseVisitorUnitTests method shouldApplyNamingStrategy.
// DATAJDBC-309
@Test
void shouldApplyNamingStrategy() {
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.toUpper()));
select.visit(visitor);
assertThat(visitor.getRenderedPart().toString()).isEqualTo("EMP_NAME ASC");
}
use of org.springframework.data.relational.core.sql.Column in project spring-data-jdbc by spring-projects.
the class OrderByClauseVisitorUnitTests method shouldRenderOrderByFullyQualifiedNameWithTableAlias.
// GH-968
@Test
void shouldRenderOrderByFullyQualifiedNameWithTableAlias() {
Table employee = SQL.table("employee").as("emp");
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("emp.name ASC");
}
use of org.springframework.data.relational.core.sql.Column in project spring-data-jdbc by spring-projects.
the class NameRendererUnitTests method fullyQualifiedReferenceWithAlias.
// GH-1003, GH-968
@Test
void fullyQualifiedReferenceWithAlias() {
Column column = Column.aliased("col", Table.aliased("table", "tab_alias"), "col_alias");
CharSequence rendered = NameRenderer.fullyQualifiedReference(context, column);
assertThat(rendered).isEqualTo("col_alias");
}
use of org.springframework.data.relational.core.sql.Column in project spring-data-jdbc by spring-projects.
the class UpdateRendererUnitTests method shouldRenderUpdateWithLiteral.
// DATAJDBC-335
@Test
public void shouldRenderUpdateWithLiteral() {
Table table = SQL.table("mytable");
Column column = table.column("foo");
Update update = StatementBuilder.update(table).set(column.set(SQL.literalOf(20))).build();
assertThat(SqlRenderer.toString(update)).isEqualTo("UPDATE mytable SET foo = 20");
}
use of org.springframework.data.relational.core.sql.Column in project spring-data-jdbc by spring-projects.
the class UpdateRendererUnitTests method shouldRenderSimpleUpdate.
// DATAJDBC-335
@Test
public void shouldRenderSimpleUpdate() {
Table table = SQL.table("mytable");
Column column = table.column("foo");
Update update = StatementBuilder.update(table).set(column.set(SQL.bindMarker())).build();
assertThat(SqlRenderer.toString(update)).isEqualTo("UPDATE mytable SET foo = ?");
}
Aggregations