Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in SQL query in TransactionMethods.selectById() #151

Closed
jackrua opened this issue Feb 8, 2024 · 1 comment
Closed

Error in SQL query in TransactionMethods.selectById() #151

jackrua opened this issue Feb 8, 2024 · 1 comment
Assignees

Comments

@jackrua
Copy link
Contributor

jackrua commented Feb 8, 2024

While working on #149, I have noticed that this query returns an error:

Future<Transaction> selectById(int id) async {
final db = await database;
final maps = await db.rawQuery('SELECT t.*, c.${CategoryTransactionFields.name} as ${TransactionFields.categoryName}, c.${CategoryTransactionFields.color} as ${TransactionFields.categoryColor}, c.${CategoryTransactionFields.symbol} as ${TransactionFields.categorySymbol}, b1.${BankAccountFields.name} as ${TransactionFields.bankAccountName}, b2.${BankAccountFields.name} as ${TransactionFields.bankAccountTransferName} FROM $transactionTable as t LEFT JOIN $categoryTransactionTable as c ON t.${TransactionFields.idCategory} = c.${CategoryTransactionFields.id} LEFT JOIN $bankAccountTable as b1 ON t.${TransactionFields.idBankAccount} = b1.${BankAccountFields.id} LEFT JOIN $bankAccountTable as b2 ON t.${TransactionFields.idBankAccountTransfer} = b2.${BankAccountFields.id} WHERE t.${TransactionFields.id} = ?', [id]);
if (maps.isNotEmpty) {
return Transaction.fromJson(maps.first);
} else {
throw Exception('ID $id not found');
}
}

The fix is easy but I would rather close this issue before moving on to push the whole PR.

@theperu
Copy link
Collaborator

theperu commented Feb 8, 2024

IMHO you can open just one PR with both fixes, maybe you could have separated commits and make it also clear in the description of the PR itself

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants