Search in sources :

Example 16 with Column

use of org.springframework.data.relational.core.sql.Column in project spring-data-jdbc by spring-projects.

the class ExpressionVisitorUnitTests method renderAliasedExpressionWithAliasHandlingUse.

// GH-1003
@Test
void renderAliasedExpressionWithAliasHandlingUse() {
    ExpressionVisitor visitor = new ExpressionVisitor(simpleRenderContext, ExpressionVisitor.AliasHandling.USE);
    Column expression = Column.aliased("col", Table.create("tab"), "col_alias");
    expression.visit(visitor);
    assertThat(visitor.getRenderedPart().toString()).isEqualTo("col_alias");
}
Also used : Column(org.springframework.data.relational.core.sql.Column) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 17 with Column

use of org.springframework.data.relational.core.sql.Column in project spring-data-jdbc by spring-projects.

the class ExpressionVisitorUnitTests method renderAliasedExpressionWithAliasHandlingDeclare.

// GH-1003
@Test
void renderAliasedExpressionWithAliasHandlingDeclare() {
    ExpressionVisitor visitor = new ExpressionVisitor(simpleRenderContext, ExpressionVisitor.AliasHandling.IGNORE);
    Column expression = Column.aliased("col", Table.create("tab"), "col_alias");
    expression.visit(visitor);
    assertThat(visitor.getRenderedPart().toString()).isEqualTo("tab.col");
}
Also used : Column(org.springframework.data.relational.core.sql.Column) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Column (org.springframework.data.relational.core.sql.Column)17 Test (org.junit.jupiter.api.Test)14 Table (org.springframework.data.relational.core.sql.Table)9 Select (org.springframework.data.relational.core.sql.Select)5 Update (org.springframework.data.relational.core.sql.Update)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 SelectBuilder (org.springframework.data.relational.core.sql.SelectBuilder)2 ArrayList (java.util.ArrayList)1 PersistentPropertyPathExtension (org.springframework.data.relational.core.mapping.PersistentPropertyPathExtension)1 RelationalPersistentProperty (org.springframework.data.relational.core.mapping.RelationalPersistentProperty)1 Expression (org.springframework.data.relational.core.sql.Expression)1 InlineQuery (org.springframework.data.relational.core.sql.InlineQuery)1 TestJoin (org.springframework.data.relational.core.sql.TestJoin)1