@entity-access/entity-access 1.0.201 → 1.0.203
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/ObjectPool.d.ts +1 -1
- package/dist/common/ObjectPool.d.ts.map +1 -1
- package/dist/common/ObjectPool.js +1 -1
- package/dist/common/ObjectPool.js.map +1 -1
- package/dist/compiler/QueryCompiler.d.ts +2 -1
- package/dist/compiler/QueryCompiler.d.ts.map +1 -1
- package/dist/compiler/QueryCompiler.js +2 -3
- package/dist/compiler/QueryCompiler.js.map +1 -1
- package/dist/drivers/postgres/PostgreSqlDriver.js +1 -1
- package/dist/drivers/postgres/PostgreSqlDriver.js.map +1 -1
- package/dist/drivers/sql-server/SqlServerQueryCompiler.d.ts +1 -1
- package/dist/drivers/sql-server/SqlServerQueryCompiler.d.ts.map +1 -1
- package/dist/drivers/sql-server/SqlServerQueryCompiler.js +2 -3
- package/dist/drivers/sql-server/SqlServerQueryCompiler.js.map +1 -1
- package/dist/entity-query/EntityType.d.ts +4 -3
- package/dist/entity-query/EntityType.d.ts.map +1 -1
- package/dist/entity-query/EntityType.js +14 -9
- package/dist/entity-query/EntityType.js.map +1 -1
- package/dist/model/EntityModel.d.ts.map +1 -1
- package/dist/model/EntityModel.js +4 -1
- package/dist/model/EntityModel.js.map +1 -1
- package/dist/model/EntityQuery.d.ts.map +1 -1
- package/dist/model/EntityQuery.js +13 -4
- package/dist/model/EntityQuery.js.map +1 -1
- package/dist/query/ast/ExpressionToSql.d.ts.map +1 -1
- package/dist/query/ast/ExpressionToSql.js +12 -6
- package/dist/query/ast/ExpressionToSql.js.map +1 -1
- package/dist/query/ast/Expressions.d.ts +2 -0
- package/dist/query/ast/Expressions.d.ts.map +1 -1
- package/dist/query/ast/Expressions.js +3 -0
- package/dist/query/ast/Expressions.js.map +1 -1
- package/dist/tests/db-tests/tests/select-map.d.ts +3 -0
- package/dist/tests/db-tests/tests/select-map.d.ts.map +1 -0
- package/dist/tests/db-tests/tests/select-map.js +12 -0
- package/dist/tests/db-tests/tests/select-map.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/common/ObjectPool.ts +1 -1
- package/src/compiler/QueryCompiler.ts +3 -2
- package/src/drivers/postgres/PostgreSqlDriver.ts +1 -1
- package/src/drivers/sql-server/SqlServerQueryCompiler.ts +2 -1
- package/src/entity-query/EntityType.ts +17 -10
- package/src/model/EntityModel.ts +9 -2
- package/src/model/EntityQuery.ts +14 -4
- package/src/query/ast/ExpressionToSql.ts +12 -6
- package/src/query/ast/Expressions.ts +5 -0
- package/src/tests/db-tests/tests/select-map.ts +19 -0
|
@@ -323,7 +323,9 @@ export default class ExpressionToSql extends Visitor<ITextQuery> {
|
|
|
323
323
|
}
|
|
324
324
|
|
|
325
325
|
visitIdentifier(e: Identifier): ITextQuery {
|
|
326
|
-
|
|
326
|
+
if (e.quoted) {
|
|
327
|
+
return [this.compiler.quote(e.value)];
|
|
328
|
+
}
|
|
327
329
|
return [e.value];
|
|
328
330
|
}
|
|
329
331
|
|
|
@@ -358,10 +360,10 @@ export default class ExpressionToSql extends Visitor<ITextQuery> {
|
|
|
358
360
|
const name = this.scope.nameOf(parameter);
|
|
359
361
|
|
|
360
362
|
// need to change name as per naming convention here...
|
|
361
|
-
const namingConvention = this.compiler.namingConvention;
|
|
362
|
-
if (scope.model && namingConvention) {
|
|
363
|
-
|
|
364
|
-
}
|
|
363
|
+
// const namingConvention = this.compiler.namingConvention;
|
|
364
|
+
// if (scope.model && namingConvention) {
|
|
365
|
+
// chain[0] = namingConvention(chain[0]);
|
|
366
|
+
// }
|
|
365
367
|
|
|
366
368
|
return [ QueryParameter.create(() => name) , "." , chain.join(".")];
|
|
367
369
|
}
|
|
@@ -669,7 +671,11 @@ export default class ExpressionToSql extends Visitor<ITextQuery> {
|
|
|
669
671
|
const scope = this.scope.get(pe);
|
|
670
672
|
const peModel = scope?.model;
|
|
671
673
|
if (peModel) {
|
|
672
|
-
const { relation } = peModel.getProperty(id.value);
|
|
674
|
+
const { relation, field } = peModel.getProperty(id.value);
|
|
675
|
+
if (field) {
|
|
676
|
+
// we need to replace field with column name...
|
|
677
|
+
return Expression.member(target, field.columnName);
|
|
678
|
+
}
|
|
673
679
|
if (relation) {
|
|
674
680
|
|
|
675
681
|
const { fkColumn } = relation;
|
|
@@ -66,6 +66,10 @@ export abstract class Expression {
|
|
|
66
66
|
return Identifier.create({ value: name });
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
static quotedIdentifier(name: string) {
|
|
70
|
+
return Identifier.create({ value: name, quoted: true });
|
|
71
|
+
}
|
|
72
|
+
|
|
69
73
|
static logicalAnd(left: Expression, right: Expression): BinaryExpression {
|
|
70
74
|
return BinaryExpression.create({ left, operator: "AND", right});
|
|
71
75
|
}
|
|
@@ -307,6 +311,7 @@ export class Constant extends Expression {
|
|
|
307
311
|
export class Identifier extends Expression {
|
|
308
312
|
readonly type = "Identifier";
|
|
309
313
|
public value: string;
|
|
314
|
+
public quoted: boolean;
|
|
310
315
|
}
|
|
311
316
|
|
|
312
317
|
export class NullExpression extends Expression {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import assert from "assert";
|
|
2
|
+
import { TestConfig } from "../../TestConfig.js";
|
|
3
|
+
import { createContext, headPhoneCategory } from "../../model/createContext.js";
|
|
4
|
+
import Sql from "../../../sql/Sql.js";
|
|
5
|
+
|
|
6
|
+
export default async function(this: TestConfig) {
|
|
7
|
+
|
|
8
|
+
if (!this.db) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const context = await createContext(this.driver);
|
|
13
|
+
|
|
14
|
+
const f = await context.orderItems.all()
|
|
15
|
+
.map({}, (p) => ({ orderID, amount }) => ({ orderID, amount }))
|
|
16
|
+
.first();
|
|
17
|
+
|
|
18
|
+
console.log(f);
|
|
19
|
+
}
|