Skip to content

Commit

Permalink
chore: Fix field selections (#83)
Browse files Browse the repository at this point in the history
* fix field selections

* _

* bump orm version

* _
  • Loading branch information
codekeyz authored Nov 5, 2024
1 parent bd66e52 commit 04546ad
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.0.4

- Make Entity a mixin.
- Fixed orderBy query.
- Minor improvements.

## 0.0.3

- Separate code-gen package from yaroorm.
Expand Down
6 changes: 3 additions & 3 deletions lib/src/database/driver/sqlite_driver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class SqliteSerializer extends PrimitiveSerializer {
/// ORDER BY
final orderBys = query.orderByProps ?? {};
if (orderBys.isNotEmpty) {
queryBuilder.write(' ORDER BY ${acceptOrderBy(orderBys.toList())}');
queryBuilder.write(' ORDER BY ${acceptOrderBy(tableName, orderBys.toList())}');
}

/// LIMIT
Expand Down Expand Up @@ -341,9 +341,9 @@ class SqliteSerializer extends PrimitiveSerializer {
}

@override
String acceptOrderBy(List<OrderBy> orderBys) {
String acceptOrderBy(String tableName, List<OrderBy> orderBys) {
direction(OrderDirection dir) => dir == OrderDirection.asc ? 'ASC' : 'DESC';
return orderBys.map((e) => '${e.field} ${direction(e.direction)}').join(', ');
return orderBys.map((e) => '$tableName.${escapeStr(e.field)} ${direction(e.direction)}').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 @@ -22,7 +22,7 @@ abstract class PrimitiveSerializer {

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

String acceptOrderBy(List<OrderBy> orderBys);
String acceptOrderBy(String tableName, List<OrderBy> orderBys);

String acceptLimit(int limit);

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: yaroorm
description: Easy migrations, query-builder & ORM for Postgres, SQLite, MySQL & MariaDB.
version: 0.0.3+2
version: 0.0.4
homepage: https://docs.yaroo.dev/orm/quickstart
repository: https://github.com/codekeyz/yaroo

Expand Down

0 comments on commit 04546ad

Please sign in to comment.