From c26ee9011e608c02fa01c0dcdfb991423fe4ff5b Mon Sep 17 00:00:00 2001 From: Chima Precious Date: Sun, 28 Apr 2024 01:13:43 +0000 Subject: [PATCH] tiny fix --- lib/src/database/driver/sqlite_driver.dart | 14 +++++++++----- lib/src/primitives/serializer.dart | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/src/database/driver/sqlite_driver.dart b/lib/src/database/driver/sqlite_driver.dart index d6399850..c885da07 100644 --- a/lib/src/database/driver/sqlite_driver.dart +++ b/lib/src/database/driver/sqlite_driver.dart @@ -207,9 +207,11 @@ class SqliteSerializer extends PrimitiveSerializer { final queryBuilder = StringBuffer(); /// SELECT - final selectStatement = acceptSelect(query.fieldSelections.toList()); - queryBuilder.write(selectStatement); - queryBuilder.write('FROM ${escapeStr(query.tableName)}'); + final tableName = escapeStr(query.tableName); + final selectStatement = acceptSelect(tableName, query.fieldSelections.toList()); + queryBuilder + ..write(selectStatement) + ..write('FROM $tableName'); /// WHERE final whereClause = query.whereClause; @@ -311,8 +313,10 @@ class SqliteSerializer extends PrimitiveSerializer { } @override - String acceptSelect(List fields) { - return fields.isEmpty ? 'SELECT * ' : 'SELECT ${fields.map(escapeStr).join(', ')} '; + String acceptSelect(String tableName, List fields) { + return fields.isEmpty + ? 'SELECT $tableName.* ' + : 'SELECT ${fields.map((e) => '$tableName.${escapeStr(e)}').join(', ')} '; } @override diff --git a/lib/src/primitives/serializer.dart b/lib/src/primitives/serializer.dart index 026161e5..f24a04b0 100644 --- a/lib/src/primitives/serializer.dart +++ b/lib/src/primitives/serializer.dart @@ -20,7 +20,7 @@ abstract class PrimitiveSerializer { String acceptWhereClauseValue(WhereClauseValue clauseValue); - String acceptSelect(List fields); + String acceptSelect(String tableName, List fields); String acceptOrderBy(List orderBys);