Skip to content

Commit

Permalink
tiny fix
Browse files Browse the repository at this point in the history
  • Loading branch information
codekeyz committed Apr 28, 2024
1 parent 4b1622c commit c26ee90
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions lib/src/database/driver/sqlite_driver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -311,8 +313,10 @@ class SqliteSerializer extends PrimitiveSerializer {
}

@override
String acceptSelect(List<String> fields) {
return fields.isEmpty ? 'SELECT * ' : 'SELECT ${fields.map(escapeStr).join(', ')} ';
String acceptSelect(String tableName, List<String> fields) {
return fields.isEmpty
? 'SELECT $tableName.* '
: 'SELECT ${fields.map((e) => '$tableName.${escapeStr(e)}').join(', ')} ';
}

@override
Expand Down
2 changes: 1 addition & 1 deletion lib/src/primitives/serializer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ abstract class PrimitiveSerializer {

String acceptWhereClauseValue(WhereClauseValue clauseValue);

String acceptSelect(List<String> fields);
String acceptSelect(String tableName, List<String> fields);

String acceptOrderBy(List<OrderBy> orderBys);

Expand Down

0 comments on commit c26ee90

Please sign in to comment.