From e90bba935e1fc581a7688f5be0f5dc921abc2942 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Sat, 12 Oct 2019 23:20:07 -0400 Subject: [PATCH] * Remove parentheses from `AS` when renaming raw `expressions`. --- angel_orm/CHANGELOG.md | 3 +++ angel_orm/lib/src/query.dart | 11 +++++++---- angel_orm/pubspec.yaml | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/angel_orm/CHANGELOG.md b/angel_orm/CHANGELOG.md index bf3e0adc..8f193561 100644 --- a/angel_orm/CHANGELOG.md +++ b/angel_orm/CHANGELOG.md @@ -1,3 +1,6 @@ +# 2.1.0-beta.3 +* Remove parentheses from `AS` when renaming raw `expressions`. + # 2.1.0-beta.2 * Add `expressions` to `Query`, to support custom SQL expressions that are read as normal fields. diff --git a/angel_orm/lib/src/query.dart b/angel_orm/lib/src/query.dart index 6dbe979f..84ce78cf 100644 --- a/angel_orm/lib/src/query.dart +++ b/angel_orm/lib/src/query.dart @@ -42,7 +42,8 @@ abstract class Query extends QueryBase { /// Preprends the [tableName] to the [String], [s]. String adornWithTableName(String s) { if (expressions.containsKey(s)) { - return '(${expressions[s]} AS $s)'; + return '${expressions[s]} AS $s'; + // return '(${expressions[s]} AS $s)'; } else { return '$tableName.$s'; } @@ -256,13 +257,15 @@ abstract class Query extends QueryBase { ss = '$ss AS ${aliases[s]}'; } if (expressions.containsKey(s)) { - ss = '($ss)'; + // ss = '($ss)'; } } else if (expressions.containsKey(s)) { if (cast != null) { - ss = '(($ss) AS $s)'; + ss = '($ss) AS $s'; + // ss = '(($ss) AS $s)'; } else { - ss = '($ss AS $s)'; + ss = '$ss AS $s'; + // ss = '($ss AS $s)'; } } return ss; diff --git a/angel_orm/pubspec.yaml b/angel_orm/pubspec.yaml index 09b60aa3..1b7fc2e4 100644 --- a/angel_orm/pubspec.yaml +++ b/angel_orm/pubspec.yaml @@ -1,5 +1,5 @@ name: angel_orm -version: 2.1.0-beta.2 +version: 2.1.0-beta.3 description: Runtime support for Angel's ORM. Includes base classes for queries. author: Tobe O homepage: https://github.com/angel-dart/orm