Carter
Carter

Reputation: 179

Why isn't my sql query in sqlite/sqlbrite not working with a second condition/multiple WHERE clauses?

I have a query for my Sqlite/Brite databse that takes two conditions. One to check for a selected quarter, and another to make sure an action attribute isn't "delete". When I only have the WHERE clause to check for the selected quarter, I get all the data I want. When I add the WHERE clause to check to make sure it doesn't have a "deleted" attribute, nothing comes back. Nothing should have a deleted attribute so all the same data should come back, but it isn't. Why is this?

Heres the function that's causing me the issues

 Stream<List<dynamic>> getTransaction() async* {
    List _transaction = [];
    final sessionData = await getSession();
    final db = await initDatabase();
    yield* db.createQuery(
        "transactions",
        where: 'action != "delete" AND transaction_quarter = ? ',
        whereArgs: [sessionData['selected_quarter']]
    ).mapToList((row) => TransModel.Transaction.fromMap(row));
  }

Upvotes: -1

Views: 92

Answers (2)

Oleg Plotnikov
Oleg Plotnikov

Reputation: 315

You can try to pass "delete" in args

db.createQuery(
        "transactions",
        where: 'action != ? AND transaction_quarter = ? ',
        whereArgs: ["delete", sessionData['selected_quarter']]
    )

Upvotes: 0

Randal Schwartz
Randal Schwartz

Reputation: 44081

it looks like you have "delete" in your SQL. I think you'll need 'delete'. They are definitely not the same.

Upvotes: 0

Related Questions