Search in sources :

Example 11 with SqlDelightStatement

use of com.squareup.sqldelight.SqlDelightStatement in project sqldelight by square.

the class IntegrationTests method namedIndexArgs.

@Test
public void namedIndexArgs() {
    // :name is the only arg
    SqlDelightStatement equivalentNames = Person.FACTORY.equivalent_names_named("Bob");
    Cursor cursor = database.rawQuery(equivalentNames.statement, equivalentNames.args);
    assertThat(cursor.getCount()).isEqualTo(1);
    cursor.moveToFirst();
    Person person = Person.FACTORY.equivalent_names_namedMapper().map(cursor);
    assertThat(person).isEqualTo(new AutoValue_Person(4, "Bob", "Bob"));
}
Also used : SqlDelightStatement(com.squareup.sqldelight.SqlDelightStatement) Cursor(android.database.Cursor) Test(org.junit.Test)

Example 12 with SqlDelightStatement

use of com.squareup.sqldelight.SqlDelightStatement in project sqldelight by square.

the class IntegrationTests method startIndexAtTwo.

@Test
public void startIndexAtTwo() {
    // ?2 is the only arg
    SqlDelightStatement equivalentNames = Person.FACTORY.equivalent_names_2("Bob");
    Cursor cursor = database.rawQuery(equivalentNames.statement, equivalentNames.args);
    assertThat(cursor.getCount()).isEqualTo(1);
    cursor.moveToFirst();
    Person person = Person.FACTORY.equivalent_names_2Mapper().map(cursor);
    assertThat(person).isEqualTo(new AutoValue_Person(4, "Bob", "Bob"));
}
Also used : SqlDelightStatement(com.squareup.sqldelight.SqlDelightStatement) Cursor(android.database.Cursor) Test(org.junit.Test)

Aggregations

SqlDelightStatement (com.squareup.sqldelight.SqlDelightStatement)12 Cursor (android.database.Cursor)11 Test (org.junit.Test)11 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1 CountDownLatch (java.util.concurrent.CountDownLatch)1