@entity-access/entity-access 1.0.345 → 1.0.347
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/migrations/postgres/PostgresAutomaticMigrations.js +1 -1
- package/dist/migrations/postgres/PostgresAutomaticMigrations.js.map +1 -1
- package/dist/query/ast/DebugStringVisitor.d.ts +2 -1
- package/dist/query/ast/DebugStringVisitor.d.ts.map +1 -1
- package/dist/query/ast/DebugStringVisitor.js +3 -0
- package/dist/query/ast/DebugStringVisitor.js.map +1 -1
- package/dist/query/ast/ExpressionToSql.d.ts +2 -1
- package/dist/query/ast/ExpressionToSql.d.ts.map +1 -1
- package/dist/query/ast/ExpressionToSql.js +3 -0
- package/dist/query/ast/ExpressionToSql.js.map +1 -1
- package/dist/query/ast/Expressions.d.ts +5 -1
- package/dist/query/ast/Expressions.d.ts.map +1 -1
- package/dist/query/ast/Expressions.js +6 -0
- package/dist/query/ast/Expressions.js.map +1 -1
- package/dist/query/ast/Visitor.d.ts +2 -1
- package/dist/query/ast/Visitor.d.ts.map +1 -1
- package/dist/query/ast/Visitor.js +5 -0
- package/dist/query/ast/Visitor.js.map +1 -1
- package/dist/query/parser/ArrowToExpression.d.ts.map +1 -1
- package/dist/query/parser/ArrowToExpression.js +5 -1
- package/dist/query/parser/ArrowToExpression.js.map +1 -1
- package/dist/query/parser/Restructure.d.ts.map +1 -1
- package/dist/query/parser/Restructure.js +5 -0
- package/dist/query/parser/Restructure.js.map +1 -1
- package/dist/tests/expressions/simple/parse-complex.d.ts +2 -0
- package/dist/tests/expressions/simple/parse-complex.d.ts.map +1 -0
- package/dist/tests/expressions/simple/parse-complex.js +11 -0
- package/dist/tests/expressions/simple/parse-complex.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/migrations/postgres/PostgresAutomaticMigrations.ts +1 -1
- package/src/query/ast/DebugStringVisitor.ts +6 -1
- package/src/query/ast/ExpressionToSql.ts +5 -1
- package/src/query/ast/Expressions.ts +6 -0
- package/src/query/ast/Visitor.ts +6 -1
- package/src/query/parser/ArrowToExpression.ts +5 -1
- package/src/query/parser/Restructure.ts +5 -0
- package/src/tests/expressions/simple/parse-complex.ts +20 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseExpression } from "@babel/parser";
|
|
2
|
-
import { ArrowFunctionExpression, BinaryExpression, BooleanLiteral, BracketExpression, CallExpression, CoalesceExpression, ConditionalExpression, Constant, Expression, ExpressionAs, Identifier, MemberExpression, NewObjectExpression, NotExpression, NullExpression, NumberLiteral, ParameterExpression, StringLiteral, TemplateLiteral } from "../ast/Expressions.js";
|
|
2
|
+
import { ArrowFunctionExpression, BinaryExpression, BooleanLiteral, BracketExpression, CallExpression, CoalesceExpression, ConditionalExpression, Constant, Expression, ExpressionAs, Identifier, MemberExpression, NegateExpression, NewObjectExpression, NotExpression, NullExpression, NumberLiteral, ParameterExpression, StringLiteral, TemplateLiteral } from "../ast/Expressions.js";
|
|
3
3
|
import { BabelVisitor } from "./BabelVisitor.js";
|
|
4
4
|
import * as bpe from "@babel/types";
|
|
5
5
|
import Restructure from "./Restructure.js";
|
|
@@ -129,6 +129,10 @@ export default class ArrowToExpression extends BabelVisitor<Expression> {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
visitUnaryExpression(node: bpe.UnaryExpression): Expression {
|
|
132
|
+
switch(node.operator) {
|
|
133
|
+
case "-":
|
|
134
|
+
return NegateExpression.create({ expression: this.visit(node.argument)});
|
|
135
|
+
}
|
|
132
136
|
return NotExpression.create({ expression: this.visit(node.argument)});
|
|
133
137
|
}
|
|
134
138
|
|
|
@@ -8,6 +8,11 @@ export default class Restructure extends TransformVisitor {
|
|
|
8
8
|
private map: Map<string, bpe.Node> = new Map();
|
|
9
9
|
|
|
10
10
|
visitUnaryExpression(node: bpe.UnaryExpression): bpe.Node {
|
|
11
|
+
if (node.operator === "-") {
|
|
12
|
+
if (node.argument.type === "NumericLiteral") {
|
|
13
|
+
return bpe.numericLiteral(-node.argument.value);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
11
16
|
return node;
|
|
12
17
|
}
|
|
13
18
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import assert from "assert";
|
|
2
|
+
import Sql from "../../../sql/Sql.js";
|
|
3
|
+
import QueryCompiler from "../../../compiler/QueryCompiler.js";
|
|
4
|
+
|
|
5
|
+
export default function () {
|
|
6
|
+
|
|
7
|
+
const compiler = QueryCompiler.instance;
|
|
8
|
+
|
|
9
|
+
const name = "Akash";
|
|
10
|
+
|
|
11
|
+
let r = compiler.execute({ name }, (p) => (x) => x.id ? 1 : -1);
|
|
12
|
+
assert.equal("(CASE WHEN x.id THEN 1 ELSE -1 END)", r.text);
|
|
13
|
+
|
|
14
|
+
r = compiler.execute({ name }, (p) => (x) => x.id ? 1 : -(5*1));
|
|
15
|
+
assert.equal("(CASE WHEN x.id THEN 1 ELSE (-5 * 1) END)", r.text);
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type KeyCode = { name: string, code: number, key: string };
|