Search in sources :

Example 1 with SimpleSQLiteQuery

use of android.arch.persistence.db.SimpleSQLiteQuery in project sqlbrite by square.

the class BriteDatabaseTest method synchronousQueryWithSupportSQLiteQueryDuringTransactionSeesChanges.

@Test
public void synchronousQueryWithSupportSQLiteQueryDuringTransactionSeesChanges() {
    Transaction transaction = db.newTransaction();
    try {
        assertCursor(db.query(new SimpleSQLiteQuery(SELECT_EMPLOYEES))).hasRow("alice", "Alice Allison").hasRow("bob", "Bob Bobberson").hasRow("eve", "Eve Evenson").isExhausted();
        db.insert(TABLE_EMPLOYEE, CONFLICT_NONE, employee("john", "John Johnson"));
        db.insert(TABLE_EMPLOYEE, CONFLICT_NONE, employee("nick", "Nick Nickers"));
        assertCursor(db.query(new SimpleSQLiteQuery(SELECT_EMPLOYEES))).hasRow("alice", "Alice Allison").hasRow("bob", "Bob Bobberson").hasRow("eve", "Eve Evenson").hasRow("john", "John Johnson").hasRow("nick", "Nick Nickers").isExhausted();
        transaction.markSuccessful();
    } finally {
        transaction.end();
    }
}
Also used : Transaction(com.squareup.sqlbrite3.BriteDatabase.Transaction) SimpleSQLiteQuery(android.arch.persistence.db.SimpleSQLiteQuery) Test(org.junit.Test)

Example 2 with SimpleSQLiteQuery

use of android.arch.persistence.db.SimpleSQLiteQuery in project sqlbrite by square.

the class BriteDatabaseTest method synchronousQueryWithSupportSQLiteQueryDuringTransaction.

@Test
public void synchronousQueryWithSupportSQLiteQueryDuringTransaction() {
    Transaction transaction = db.newTransaction();
    try {
        transaction.markSuccessful();
        assertCursor(db.query(new SimpleSQLiteQuery(SELECT_EMPLOYEES))).hasRow("alice", "Alice Allison").hasRow("bob", "Bob Bobberson").hasRow("eve", "Eve Evenson").isExhausted();
    } finally {
        transaction.end();
    }
}
Also used : Transaction(com.squareup.sqlbrite3.BriteDatabase.Transaction) SimpleSQLiteQuery(android.arch.persistence.db.SimpleSQLiteQuery) Test(org.junit.Test)

Aggregations

SimpleSQLiteQuery (android.arch.persistence.db.SimpleSQLiteQuery)2 Transaction (com.squareup.sqlbrite3.BriteDatabase.Transaction)2 Test (org.junit.Test)2