@abedmurrar/objection 4.0.0-beta.3 → 4.0.0-beta.4
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/lib/queryBuilder/FunctionBuilder.js +35 -31
- package/lib/queryBuilder/JoinBuilder.js +46 -45
- package/lib/queryBuilder/RawBuilder.js +15 -13
- package/lib/queryBuilder/ReferenceBuilder.js +25 -23
- package/lib/queryBuilder/RelationExpression.js +59 -19
- package/lib/queryBuilder/ValueBuilder.js +20 -19
- package/lib/queryBuilder/expressions.js +8 -18
- package/lib/queryBuilder/functions/mysql.js +18 -42
- package/lib/queryBuilder/join/JoinResultColumn.js +6 -4
- package/lib/queryBuilder/join/JoinResultParser.js +10 -8
- package/lib/queryBuilder/join/RelationJoiner.js +40 -35
- package/lib/queryBuilder/join/TableNode.js +7 -5
- package/lib/queryBuilder/join/TableTree.js +13 -9
- package/lib/queryBuilder/join/utils.js +8 -8
- package/package.json +1 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TableNode = void 0;
|
|
2
4
|
class TableNode {
|
|
3
|
-
constructor({ tableTree, modelClass, expression, parentNode = null, relation = null }) {
|
|
5
|
+
constructor({ tableTree, modelClass, expression, parentNode = null, relation = null, }) {
|
|
4
6
|
this.tableTree = tableTree;
|
|
5
7
|
this.modelClass = modelClass;
|
|
6
8
|
this.parentNode = parentNode;
|
|
@@ -20,6 +22,7 @@ class TableNode {
|
|
|
20
22
|
get options() {
|
|
21
23
|
return this.tableTree.options;
|
|
22
24
|
}
|
|
25
|
+
// Null for the root node only.
|
|
23
26
|
get relationProperty() {
|
|
24
27
|
return this.expression.node.$name;
|
|
25
28
|
}
|
|
@@ -57,6 +60,7 @@ class TableNode {
|
|
|
57
60
|
}
|
|
58
61
|
_calculateAlias() {
|
|
59
62
|
if (this.parentNode) {
|
|
63
|
+
// A child node always has a name.
|
|
60
64
|
const relationName = this.expression.node.$name;
|
|
61
65
|
const alias = this.options.aliases[relationName] || relationName;
|
|
62
66
|
if (this.options.minimize) {
|
|
@@ -84,6 +88,7 @@ class TableNode {
|
|
|
84
88
|
}
|
|
85
89
|
}
|
|
86
90
|
}
|
|
91
|
+
exports.TableNode = TableNode;
|
|
87
92
|
function createIdGetter(columnAliases) {
|
|
88
93
|
const columnAlias = columnAliases[0];
|
|
89
94
|
return (flatRow) => {
|
|
@@ -131,6 +136,3 @@ function createMultiIdGetter(columnAliases) {
|
|
|
131
136
|
return idStr;
|
|
132
137
|
};
|
|
133
138
|
}
|
|
134
|
-
module.exports = {
|
|
135
|
-
TableNode,
|
|
136
|
-
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TableTree = void 0;
|
|
4
|
+
const utils_1 = require("./utils");
|
|
5
|
+
const TableNode_1 = require("./TableNode");
|
|
4
6
|
class TableTree {
|
|
5
7
|
constructor({ expression, rootModelClass, rootTableAlias, options }) {
|
|
6
8
|
this.options = options;
|
|
@@ -38,7 +40,7 @@ class TableTree {
|
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
_createRootNode({ expression, modelClass }) {
|
|
41
|
-
const node = TableNode.create({
|
|
43
|
+
const node = TableNode_1.TableNode.create({
|
|
42
44
|
tableTree: this,
|
|
43
45
|
modelClass,
|
|
44
46
|
expression,
|
|
@@ -47,8 +49,12 @@ class TableTree {
|
|
|
47
49
|
return node;
|
|
48
50
|
}
|
|
49
51
|
_createChildNodes({ expression, modelClass, parentNode }) {
|
|
50
|
-
forEachChildExpression(expression, modelClass, (childExpr, relation) => {
|
|
51
|
-
|
|
52
|
+
(0, utils_1.forEachChildExpression)(expression, modelClass, (childExpr, relation) => {
|
|
53
|
+
// `relation` is only null for a recursive relation that doesn't exist.
|
|
54
|
+
// Reading its `relatedModelClass` then throws a TypeError.
|
|
55
|
+
// `Relation` types its model classes as `RelationModelClass`. They are
|
|
56
|
+
// full model classes.
|
|
57
|
+
const node = TableNode_1.TableNode.create({
|
|
52
58
|
tableTree: this,
|
|
53
59
|
modelClass: relation.relatedModelClass,
|
|
54
60
|
expression: childExpr,
|
|
@@ -64,6 +70,4 @@ class TableTree {
|
|
|
64
70
|
});
|
|
65
71
|
}
|
|
66
72
|
}
|
|
67
|
-
|
|
68
|
-
TableTree,
|
|
69
|
-
};
|
|
73
|
+
exports.TableTree = TableTree;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RELATION_RECURSION_LIMIT = exports.ID_LENGTH_LIMIT = void 0;
|
|
4
|
+
exports.forEachChildExpression = forEachChildExpression;
|
|
5
|
+
const ValidationError_1 = require("../../model/ValidationError");
|
|
3
6
|
const ID_LENGTH_LIMIT = 63;
|
|
7
|
+
exports.ID_LENGTH_LIMIT = ID_LENGTH_LIMIT;
|
|
4
8
|
const RELATION_RECURSION_LIMIT = 64;
|
|
9
|
+
exports.RELATION_RECURSION_LIMIT = RELATION_RECURSION_LIMIT;
|
|
5
10
|
// Given a relation expression, goes through all first level children.
|
|
6
11
|
function forEachChildExpression(expr, modelClass, callback) {
|
|
7
12
|
if (expr.node.$allRecursive || expr.maxRecursionDepth > RELATION_RECURSION_LIMIT) {
|
|
8
13
|
throw modelClass.createValidationError({
|
|
9
|
-
type: ValidationErrorType.RelationExpression,
|
|
14
|
+
type: ValidationError_1.ValidationErrorType.RelationExpression,
|
|
10
15
|
message: `recursion depth of eager expression ${expr.toString()} too big for JoinEagerAlgorithm`,
|
|
11
16
|
});
|
|
12
17
|
}
|
|
13
18
|
expr.forEachChildExpression(modelClass, callback);
|
|
14
19
|
}
|
|
15
|
-
module.exports = {
|
|
16
|
-
ID_LENGTH_LIMIT,
|
|
17
|
-
RELATION_RECURSION_LIMIT,
|
|
18
|
-
forEachChildExpression,
|
|
19
|
-
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abedmurrar/objection",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.4",
|
|
4
4
|
"description": "An SQL-friendly ORM for Node.js. A fork of objection.js with strict TypeScript types and MySQL support.",
|
|
5
5
|
"main": "lib/objection.js",
|
|
6
6
|
"type": "commonjs",
|