Search in sources :

Example 6 with Table

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

the class InsertRendererUnitTests method shouldRenderInsertWithZeroColumns.

// DATAJDBC-340
@Test
public void shouldRenderInsertWithZeroColumns() {
    Table bar = SQL.table("bar");
    Insert insert = Insert.builder().into(bar).build();
    assertThat(SqlRenderer.toString(insert)).isEqualTo("INSERT INTO bar VALUES (DEFAULT)");
}
Also used : Table(org.springframework.data.relational.core.sql.Table) Insert(org.springframework.data.relational.core.sql.Insert) Test(org.junit.jupiter.api.Test)

Example 7 with Table

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

the class InsertRendererUnitTests method shouldRenderInsertColumn.

// DATAJDBC-335
@Test
public void shouldRenderInsertColumn() {
    Table bar = SQL.table("bar");
    Insert insert = Insert.builder().into(bar).column(bar.column("foo")).values(SQL.bindMarker()).build();
    assertThat(SqlRenderer.toString(insert)).isEqualTo("INSERT INTO bar (foo) VALUES (?)");
}
Also used : Table(org.springframework.data.relational.core.sql.Table) Insert(org.springframework.data.relational.core.sql.Insert) Test(org.junit.jupiter.api.Test)

Example 8 with Table

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

the class InsertRendererUnitTests method shouldRenderInsertMultipleColumns.

// DATAJDBC-335
@Test
public void shouldRenderInsertMultipleColumns() {
    Table bar = SQL.table("bar");
    Insert insert = Insert.builder().into(bar).columns(bar.columns("foo", "baz")).value(SQL.bindMarker()).value(SQL.literalOf("foo")).build();
    assertThat(SqlRenderer.toString(insert)).isEqualTo("INSERT INTO bar (foo, baz) VALUES (?, 'foo')");
}
Also used : Table(org.springframework.data.relational.core.sql.Table) Insert(org.springframework.data.relational.core.sql.Insert) Test(org.junit.jupiter.api.Test)

Example 9 with Table

use of org.springframework.data.relational.core.sql.Table 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");
}
Also used : Table(org.springframework.data.relational.core.sql.Table) Column(org.springframework.data.relational.core.sql.Column) Update(org.springframework.data.relational.core.sql.Update) Test(org.junit.jupiter.api.Test)

Example 10 with Table

use of org.springframework.data.relational.core.sql.Table 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 = ?");
}
Also used : Table(org.springframework.data.relational.core.sql.Table) Column(org.springframework.data.relational.core.sql.Column) Update(org.springframework.data.relational.core.sql.Update) Test(org.junit.jupiter.api.Test)

Aggregations

Table (org.springframework.data.relational.core.sql.Table)59 Test (org.junit.jupiter.api.Test)53 Select (org.springframework.data.relational.core.sql.Select)40 LockMode (org.springframework.data.relational.core.sql.LockMode)14 Column (org.springframework.data.relational.core.sql.Column)9 Expression (org.springframework.data.relational.core.sql.Expression)4 Insert (org.springframework.data.relational.core.sql.Insert)4 Update (org.springframework.data.relational.core.sql.Update)4 Delete (org.springframework.data.relational.core.sql.Delete)3 SqlIdentifier (org.springframework.data.relational.core.sql.SqlIdentifier)2 PersistentPropertyPathExtension (org.springframework.data.relational.core.mapping.PersistentPropertyPathExtension)1 Aliased (org.springframework.data.relational.core.sql.Aliased)1 InlineQuery (org.springframework.data.relational.core.sql.InlineQuery)1 SelectBuilder (org.springframework.data.relational.core.sql.SelectBuilder)1 TestFrom (org.springframework.data.relational.core.sql.TestFrom)1 TestJoin (org.springframework.data.relational.core.sql.TestJoin)1 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)1 Nullable (org.springframework.lang.Nullable)1