Search in sources :

Example 1 with AstInsert

use of com.developmentontheedge.sql.model.AstInsert in project be5 by DevelopmentOnTheEdge.

the class AstInsertBuildTest method testStringReplacementParameter.

@Test
public void testStringReplacementParameter() {
    AstInsert insert = Ast.insert("users").fields("name", "value").values("?", "?");
    assertEquals("INSERT INTO users (name, value) VALUES (?, ?)", insert.format());
}
Also used : AstInsert(com.developmentontheedge.sql.model.AstInsert) Test(org.junit.Test)

Example 2 with AstInsert

use of com.developmentontheedge.sql.model.AstInsert in project be5 by DevelopmentOnTheEdge.

the class AstInsertBuildTest method testStringError.

@Test(expected = ClassCastException.class)
public void testStringError() {
    AstInsert insert = Ast.insert("users").fields(3).values("Test");
    assertEquals("INSERT INTO users (name) VALUES (?)", insert.format());
}
Also used : AstInsert(com.developmentontheedge.sql.model.AstInsert) Test(org.junit.Test)

Example 3 with AstInsert

use of com.developmentontheedge.sql.model.AstInsert in project be5 by DevelopmentOnTheEdge.

the class AstInsertBuildTest method test.

@Test
public void test() {
    AstInsert insert = Ast.insert("users").fields(new AstFieldReference("name")).values(AstReplacementParameter.get());
    assertEquals("INSERT INTO users (name) VALUES (?)", insert.format());
}
Also used : AstInsert(com.developmentontheedge.sql.model.AstInsert) AstFieldReference(com.developmentontheedge.sql.model.AstFieldReference) Test(org.junit.Test)

Example 4 with AstInsert

use of com.developmentontheedge.sql.model.AstInsert in project be5 by DevelopmentOnTheEdge.

the class AstInsertBuildTest method testEscapedColumns.

@Test
public void testEscapedColumns() {
    AstInsert insert = Ast.insert("users").fields("___name").values("Test");
    assertEquals("INSERT INTO users (\"___name\") VALUES ('Test')", insert.format());
}
Also used : AstInsert(com.developmentontheedge.sql.model.AstInsert) Test(org.junit.Test)

Example 5 with AstInsert

use of com.developmentontheedge.sql.model.AstInsert in project be5 by DevelopmentOnTheEdge.

the class AstInsertBuildTest method testString.

@Test
public void testString() {
    AstInsert insert = Ast.insert("users").fields("name", "value").values("Test", 1);
    assertEquals("INSERT INTO users (name, value) VALUES ('Test', 1)", insert.format());
}
Also used : AstInsert(com.developmentontheedge.sql.model.AstInsert) Test(org.junit.Test)

Aggregations

AstInsert (com.developmentontheedge.sql.model.AstInsert)5 Test (org.junit.Test)5 AstFieldReference (com.developmentontheedge.sql.model.AstFieldReference)1