Search in sources :

Example 1 with Insert

use of org.springframework.data.relational.core.sql.Insert 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 2 with Insert

use of org.springframework.data.relational.core.sql.Insert 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 3 with Insert

use of org.springframework.data.relational.core.sql.Insert 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 4 with Insert

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

Aggregations

Test (org.junit.jupiter.api.Test)4 Insert (org.springframework.data.relational.core.sql.Insert)4 Table (org.springframework.data.relational.core.sql.Table)4