use of com.squareup.sqldelight.SqlDelightStatement in project sqldelight by square.
the class IntegrationTests method sqliteKeywordQuery.
@Test
public void sqliteKeywordQuery() {
SqlDelightStatement selectAll = SqliteKeywords.FACTORY.select_all();
Cursor cursor = database.rawQuery(selectAll.statement, selectAll.args);
assertThat(cursor.getCount()).isEqualTo(1);
cursor.moveToFirst();
SqliteKeywords sqliteKeywords = SqliteKeywords.FACTORY.select_allMapper().map(cursor);
assertThat(sqliteKeywords).isEqualTo(new AutoValue_SqliteKeywords(1, 10, 20));
}
use of com.squareup.sqldelight.SqlDelightStatement in project sqldelight by square.
the class IntegrationTests method nameIn.
@Test
public void nameIn() {
SqlDelightStatement nameIn = Person.FACTORY.name_in(new String[] { "Alec", "Matt", "Jake" });
Cursor cursor = database.rawQuery(nameIn.statement, nameIn.args);
assertThat(cursor.getCount()).isEqualTo(3);
}
use of com.squareup.sqldelight.SqlDelightStatement in project sqldelight by square.
the class IntegrationTests method marshalKeywordValues.
@Test
public void marshalKeywordValues() {
database.execSQL(SqliteKeywords.DELETE_ALL);
long newRow = database.insert(SqliteKeywords.TABLE_NAME, null, SqliteKeywords.FACTORY.marshal().where(10).having(11).asContentValues());
SqlDelightStatement selectAll = SqliteKeywords.FACTORY.select_all();
Cursor cursor = database.rawQuery(selectAll.statement, selectAll.args);
assertThat(cursor.getCount()).isEqualTo(1);
cursor.moveToFirst();
SqliteKeywords keywords = SqliteKeywords.FACTORY.select_allMapper().map(cursor);
assertThat(keywords._id()).isEqualTo(newRow);
assertThat(keywords.where()).isEqualTo(10);
assertThat(keywords.having()).isEqualTo(11);
}
use of com.squareup.sqldelight.SqlDelightStatement in project sqldelight by square.
the class PlayersActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.list);
ButterKnife.bind(this);
SQLiteDatabase db = HockeyOpenHelper.getInstance(this).getReadableDatabase();
long teamId = getIntent().getLongExtra(TEAM_ID, -1);
if (teamId == -1) {
playersCursor = db.rawQuery(Player.SELECT_ALL, new String[0]);
} else {
SqlDelightStatement playerForTeam = Player.FACTORY.for_team(teamId);
playersCursor = db.rawQuery(playerForTeam.statement, playerForTeam.args);
}
players.setAdapter(new PlayersAdapter(this, playersCursor));
}
use of com.squareup.sqldelight.SqlDelightStatement in project sqldelight by square.
the class IntegrationTests method indexedArgLast.
@Test
public void indexedArgLast() {
// First arg declared is ?, second arg declared is ?1.
SqlDelightStatement indexedArgLast = Person.FACTORY.indexed_arg_last("Bob");
Cursor cursor = database.rawQuery(indexedArgLast.statement, indexedArgLast.args);
assertThat(cursor.getCount()).isEqualTo(1);
cursor.moveToFirst();
Person person = Person.FACTORY.indexed_arg_lastMapper().map(cursor);
assertThat(person).isEqualTo(new AutoValue_Person(4, "Bob", "Bob"));
}
Aggregations