objection 3.1.1 → 3.1.3
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/README.md +2 -2
- package/lib/model/AjvValidator.js +15 -6
- package/lib/model/Model.js +1 -1
- package/lib/model/graph/ModelGraphBuilder.js +2 -2
- package/lib/model/inheritModel.js +1 -1
- package/lib/model/modelQueryProps.js +1 -1
- package/lib/model/modelSet.js +1 -1
- package/lib/model/modelTableMetadata.js +1 -1
- package/lib/queryBuilder/QueryBuilder.js +9 -9
- package/lib/queryBuilder/QueryBuilderBase.js +16 -16
- package/lib/queryBuilder/QueryBuilderOperationSupport.js +3 -3
- package/lib/queryBuilder/ReferenceBuilder.js +2 -2
- package/lib/queryBuilder/graph/GraphNodeDbExistence.js +1 -1
- package/lib/queryBuilder/graph/GraphOptions.js +1 -1
- package/lib/queryBuilder/graph/GraphUpsert.js +5 -5
- package/lib/queryBuilder/graph/delete/GraphDelete.js +1 -1
- package/lib/queryBuilder/graph/insert/GraphInsert.js +1 -1
- package/lib/queryBuilder/graph/insert/GraphInsertAction.js +1 -1
- package/lib/queryBuilder/graph/insert/JoinRowGraphInsertAction.js +3 -3
- package/lib/queryBuilder/graph/patch/GraphPatch.js +1 -1
- package/lib/queryBuilder/graph/patch/GraphPatchAction.js +1 -1
- package/lib/queryBuilder/graph/recursiveUpsert/GraphRecursiveUpsertAction.js +2 -2
- package/lib/queryBuilder/join/JoinResultParser.js +1 -1
- package/lib/queryBuilder/join/RelationJoiner.js +7 -7
- package/lib/queryBuilder/operations/FromOperation.js +1 -1
- package/lib/queryBuilder/operations/ObjectionToKnexConvertingOperation.js +3 -3
- package/lib/queryBuilder/operations/UpdateOperation.js +1 -1
- package/lib/queryBuilder/operations/UpsertGraphOperation.js +2 -2
- package/lib/queryBuilder/operations/eager/WhereInEagerOperation.js +3 -3
- package/lib/queryBuilder/operations/jsonApi/WhereJsonHasPostgresOperation.js +1 -1
- package/lib/queryBuilder/operations/jsonApi/WhereJsonNotObjectPostgresOperation.js +1 -1
- package/lib/queryBuilder/operations/jsonApi/WhereJsonPostgresOperation.js +1 -1
- package/lib/queryBuilder/operations/jsonApi/postgresJsonApi.js +3 -3
- package/lib/queryBuilder/operations/whereInComposite/WhereInCompositeMsSqlOperation.js +5 -5
- package/lib/queryBuilder/parsers/jsonFieldExpressionParser.js +3 -3
- package/lib/queryBuilder/parsers/relationExpressionParser.js +5 -5
- package/lib/relations/Relation.js +6 -6
- package/lib/relations/RelationOwner.js +1 -1
- package/lib/relations/belongsToOne/BelongsToOneUnrelateOperation.js +1 -1
- package/lib/relations/hasMany/HasManyInsertOperation.js +1 -1
- package/lib/relations/hasMany/HasManyRelateOperation.js +1 -1
- package/lib/relations/manyToMany/ManyToManyRelation.js +5 -5
- package/lib/relations/manyToMany/delete/ManyToManyDeleteSqliteOperation.js +1 -1
- package/lib/relations/manyToMany/relate/ManyToManyRelateOperation.js +3 -3
- package/lib/relations/manyToMany/unrelate/ManyToManyUnrelateSqliteOperation.js +1 -1
- package/lib/relations/manyToMany/update/ManyToManyUpdateOperationBase.js +1 -1
- package/lib/relations/manyToMany/update/ManyToManyUpdateSqliteOperation.js +1 -1
- package/lib/transaction.js +7 -7
- package/lib/utils/assert.js +1 -1
- package/lib/utils/clone.js +2 -2
- package/lib/utils/identifierMapping.js +1 -1
- package/lib/utils/normalizeIds.js +1 -1
- package/lib/utils/resolveModel.js +2 -2
- package/package.json +12 -12
- package/typings/objection/index.d.ts +91 -91
package/README.md
CHANGED
|
@@ -44,10 +44,10 @@ Check out [this issue](https://github.com/Vincit/objection.js/issues/1069) to se
|
|
|
44
44
|
|
|
45
45
|
Shortcuts:
|
|
46
46
|
|
|
47
|
-
- [Who uses objection.js](https://github.com/Vincit/objection.js/
|
|
47
|
+
- [Who uses objection.js](https://github.com/Vincit/objection.js/discussions/2464)
|
|
48
48
|
- [API reference](https://vincit.github.io/objection.js/api/query-builder/)
|
|
49
49
|
- [Example projects](https://github.com/Vincit/objection.js/tree/main/examples)
|
|
50
50
|
- [Changelog](https://vincit.github.io/objection.js/release-notes/changelog.html)
|
|
51
|
-
- [v1 -> v2 migration guide](https://vincit.github.io/objection.js/release-notes/migration.html)
|
|
51
|
+
- [v1 -> v2 -> v3 migration guide](https://vincit.github.io/objection.js/release-notes/migration.html)
|
|
52
52
|
- [Contribution guide](https://vincit.github.io/objection.js/guide/contributing.html)
|
|
53
53
|
- [Plugins](https://vincit.github.io/objection.js/guide/plugins.html)
|
|
@@ -20,8 +20,8 @@ class AjvValidator extends Validator {
|
|
|
20
20
|
{
|
|
21
21
|
useDefaults: true,
|
|
22
22
|
},
|
|
23
|
-
self.ajvOptions
|
|
24
|
-
)
|
|
23
|
+
self.ajvOptions,
|
|
24
|
+
),
|
|
25
25
|
);
|
|
26
26
|
|
|
27
27
|
// Create an instance that doesn't set default values. We need this one
|
|
@@ -29,7 +29,7 @@ class AjvValidator extends Validator {
|
|
|
29
29
|
self.ajvNoDefaults = new Ajv(
|
|
30
30
|
Object.assign({}, self.ajvOptions, {
|
|
31
31
|
useDefaults: false,
|
|
32
|
-
})
|
|
32
|
+
}),
|
|
33
33
|
);
|
|
34
34
|
|
|
35
35
|
// A cache for the compiled validator functions.
|
|
@@ -252,7 +252,7 @@ function objectHasDefaults(obj) {
|
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
function jsonSchemaWithoutRequired(jsonSchema) {
|
|
255
|
-
const subSchemaProps = ['anyOf', 'oneOf', 'allOf', 'not', 'then', 'else'];
|
|
255
|
+
const subSchemaProps = ['anyOf', 'oneOf', 'allOf', 'not', 'then', 'else', 'properties'];
|
|
256
256
|
return Object.assign(
|
|
257
257
|
omit(jsonSchema, ['required', ...subSchemaProps]),
|
|
258
258
|
...subSchemaProps.map((prop) => subSchemaWithoutRequired(jsonSchema, prop)),
|
|
@@ -261,13 +261,13 @@ function jsonSchemaWithoutRequired(jsonSchema) {
|
|
|
261
261
|
definitions: Object.assign(
|
|
262
262
|
...Object.keys(jsonSchema.definitions).map((prop) => ({
|
|
263
263
|
[prop]: jsonSchemaWithoutRequired(jsonSchema.definitions[prop]),
|
|
264
|
-
}))
|
|
264
|
+
})),
|
|
265
265
|
),
|
|
266
266
|
}
|
|
267
267
|
: {},
|
|
268
268
|
jsonSchema.discriminator && jsonSchema.discriminator.propertyName
|
|
269
269
|
? { required: [jsonSchema.discriminator.propertyName] }
|
|
270
|
-
: {}
|
|
270
|
+
: {},
|
|
271
271
|
);
|
|
272
272
|
}
|
|
273
273
|
|
|
@@ -283,6 +283,15 @@ function subSchemaWithoutRequired(jsonSchema, prop) {
|
|
|
283
283
|
} else {
|
|
284
284
|
return {};
|
|
285
285
|
}
|
|
286
|
+
} else if (jsonSchema.type === 'object' && prop === 'properties') {
|
|
287
|
+
return {
|
|
288
|
+
[prop]: Object.fromEntries(
|
|
289
|
+
Object.entries(jsonSchema[prop]).map(([key, schema]) => [
|
|
290
|
+
key,
|
|
291
|
+
jsonSchemaWithoutRequired(schema),
|
|
292
|
+
]),
|
|
293
|
+
),
|
|
294
|
+
};
|
|
286
295
|
} else {
|
|
287
296
|
return {
|
|
288
297
|
[prop]: jsonSchemaWithoutRequired(jsonSchema[prop]),
|
package/lib/model/Model.js
CHANGED
|
@@ -56,7 +56,7 @@ class ModelGraphBuilder {
|
|
|
56
56
|
parentNode,
|
|
57
57
|
node,
|
|
58
58
|
relation,
|
|
59
|
-
index
|
|
59
|
+
index,
|
|
60
60
|
);
|
|
61
61
|
|
|
62
62
|
node.parentEdge = edge;
|
|
@@ -223,7 +223,7 @@ function createReferenceNotFoundError(ref) {
|
|
|
223
223
|
`this may be due to a limitation that a subgraph under a related item`,
|
|
224
224
|
`cannot reference an item in a subgraph under another related item.`,
|
|
225
225
|
`If you run into this limitation, please open an issue in objection github.`,
|
|
226
|
-
].join(' ')
|
|
226
|
+
].join(' '),
|
|
227
227
|
);
|
|
228
228
|
}
|
|
229
229
|
|
|
@@ -130,7 +130,7 @@ function buildObjectionQueryBuilder(builder, parentBuilder) {
|
|
|
130
130
|
function buildKnexRawConvertable(convertable, builder) {
|
|
131
131
|
if (!builder) {
|
|
132
132
|
throw new Error(
|
|
133
|
-
'toDatabaseJson called without a query builder instance for a model with query properties'
|
|
133
|
+
'toDatabaseJson called without a query builder instance for a model with query properties',
|
|
134
134
|
);
|
|
135
135
|
}
|
|
136
136
|
|
package/lib/model/modelSet.js
CHANGED
|
@@ -7,7 +7,7 @@ const TABLE_METADATA = '$$tableMetadata';
|
|
|
7
7
|
|
|
8
8
|
function fetchTableMetadata(
|
|
9
9
|
modelClass,
|
|
10
|
-
{ parentBuilder = null, knex = null, force = false, table = null } = {}
|
|
10
|
+
{ parentBuilder = null, knex = null, force = false, table = null } = {},
|
|
11
11
|
) {
|
|
12
12
|
// The table isn't necessarily same as `modelClass.getTableName()` for example if
|
|
13
13
|
// a view is queried instead.
|
|
@@ -211,7 +211,7 @@ class QueryBuilder extends QueryBuilderBase {
|
|
|
211
211
|
const currentExpr = this._allowedGraphExpression || RelationExpression.create();
|
|
212
212
|
|
|
213
213
|
this._allowedGraphExpression = currentExpr.merge(
|
|
214
|
-
parseRelationExpression(this.modelClass(), exp)
|
|
214
|
+
parseRelationExpression(this.modelClass(), exp),
|
|
215
215
|
);
|
|
216
216
|
|
|
217
217
|
checkEager(this);
|
|
@@ -746,7 +746,7 @@ class QueryBuilder extends QueryBuilderBase {
|
|
|
746
746
|
return writeOperation(this, () => {
|
|
747
747
|
if (args.length) {
|
|
748
748
|
throw new Error(
|
|
749
|
-
`Don't pass arguments to delete(). You should use it like this: delete().where('foo', 'bar').andWhere(...)
|
|
749
|
+
`Don't pass arguments to delete(). You should use it like this: delete().where('foo', 'bar').andWhere(...)`,
|
|
750
750
|
);
|
|
751
751
|
}
|
|
752
752
|
|
|
@@ -771,7 +771,7 @@ class QueryBuilder extends QueryBuilderBase {
|
|
|
771
771
|
return writeOperation(this, () => {
|
|
772
772
|
if (args.length) {
|
|
773
773
|
throw new Error(
|
|
774
|
-
`Don't pass arguments to unrelate(). You should use it like this: unrelate().where('foo', 'bar').andWhere(...)
|
|
774
|
+
`Don't pass arguments to unrelate(). You should use it like this: unrelate().where('foo', 'bar').andWhere(...)`,
|
|
775
775
|
);
|
|
776
776
|
}
|
|
777
777
|
|
|
@@ -982,7 +982,7 @@ function ensureEagerOperation(builder, algorithm = null) {
|
|
|
982
982
|
} else {
|
|
983
983
|
const EagerOperationClass = getOperationClassForEagerAlgorithm(
|
|
984
984
|
builder,
|
|
985
|
-
getWhereInEagerAlgorithm(builder)
|
|
985
|
+
getWhereInEagerAlgorithm(builder),
|
|
986
986
|
);
|
|
987
987
|
|
|
988
988
|
const newEagerOp = new EagerOperationClass('eager', {
|
|
@@ -1053,7 +1053,7 @@ function checkEager(builder) {
|
|
|
1053
1053
|
modelClass.createValidationError({
|
|
1054
1054
|
type: ValidationErrorType.UnallowedRelation,
|
|
1055
1055
|
message: 'eager expression not allowed',
|
|
1056
|
-
})
|
|
1056
|
+
}),
|
|
1057
1057
|
);
|
|
1058
1058
|
}
|
|
1059
1059
|
}
|
|
@@ -1125,7 +1125,7 @@ function handleExecuteError(builder, err) {
|
|
|
1125
1125
|
builder.forEachOperation(true, (op) => {
|
|
1126
1126
|
if (op.hasOnError()) {
|
|
1127
1127
|
promise = promise.catch((err) =>
|
|
1128
|
-
builder.callAsyncOperationMethod(op, 'onError', [builder, err])
|
|
1128
|
+
builder.callAsyncOperationMethod(op, 'onError', [builder, err]),
|
|
1129
1129
|
);
|
|
1130
1130
|
}
|
|
1131
1131
|
});
|
|
@@ -1140,7 +1140,7 @@ function chainOperationHooks(promise, builder, hookName) {
|
|
|
1140
1140
|
builder.forEachOperation(true, (op) => {
|
|
1141
1141
|
if (op.hasHook(hookName)) {
|
|
1142
1142
|
promise = promise.then((result) =>
|
|
1143
|
-
builder.callAsyncOperationMethod(op, hookName, [builder, result])
|
|
1143
|
+
builder.callAsyncOperationMethod(op, hookName, [builder, result]),
|
|
1144
1144
|
);
|
|
1145
1145
|
}
|
|
1146
1146
|
});
|
|
@@ -1308,8 +1308,8 @@ function writeOperation(builder, cb) {
|
|
|
1308
1308
|
'Double call to a write method. ' +
|
|
1309
1309
|
'You can only call one of the write methods ' +
|
|
1310
1310
|
'(insert, update, patch, delete, relate, unrelate, increment, decrement) ' +
|
|
1311
|
-
'and only once per query builder.'
|
|
1312
|
-
)
|
|
1311
|
+
'and only once per query builder.',
|
|
1312
|
+
),
|
|
1313
1313
|
);
|
|
1314
1314
|
}
|
|
1315
1315
|
|
|
@@ -619,7 +619,7 @@ class QueryBuilderBase extends QueryBuilderOperationSupport {
|
|
|
619
619
|
whereJsonSupersetOf(...args) {
|
|
620
620
|
return this.addOperation(
|
|
621
621
|
new WhereJsonPostgresOperation('whereJsonSupersetOf', { operator: '@>', bool: 'and' }),
|
|
622
|
-
args
|
|
622
|
+
args,
|
|
623
623
|
);
|
|
624
624
|
}
|
|
625
625
|
|
|
@@ -630,7 +630,7 @@ class QueryBuilderBase extends QueryBuilderOperationSupport {
|
|
|
630
630
|
orWhereJsonSupersetOf(...args) {
|
|
631
631
|
return this.addOperation(
|
|
632
632
|
new WhereJsonPostgresOperation('orWhereJsonSupersetOf', { operator: '@>', bool: 'or' }),
|
|
633
|
-
args
|
|
633
|
+
args,
|
|
634
634
|
);
|
|
635
635
|
}
|
|
636
636
|
|
|
@@ -641,7 +641,7 @@ class QueryBuilderBase extends QueryBuilderOperationSupport {
|
|
|
641
641
|
bool: 'and',
|
|
642
642
|
prefix: 'not',
|
|
643
643
|
}),
|
|
644
|
-
args
|
|
644
|
+
args,
|
|
645
645
|
);
|
|
646
646
|
}
|
|
647
647
|
|
|
@@ -656,14 +656,14 @@ class QueryBuilderBase extends QueryBuilderOperationSupport {
|
|
|
656
656
|
bool: 'or',
|
|
657
657
|
prefix: 'not',
|
|
658
658
|
}),
|
|
659
|
-
args
|
|
659
|
+
args,
|
|
660
660
|
);
|
|
661
661
|
}
|
|
662
662
|
|
|
663
663
|
whereJsonSubsetOf(...args) {
|
|
664
664
|
return this.addOperation(
|
|
665
665
|
new WhereJsonPostgresOperation('whereJsonSubsetOf', { operator: '<@', bool: 'and' }),
|
|
666
|
-
args
|
|
666
|
+
args,
|
|
667
667
|
);
|
|
668
668
|
}
|
|
669
669
|
|
|
@@ -674,7 +674,7 @@ class QueryBuilderBase extends QueryBuilderOperationSupport {
|
|
|
674
674
|
orWhereJsonSubsetOf(...args) {
|
|
675
675
|
return this.addOperation(
|
|
676
676
|
new WhereJsonPostgresOperation('orWhereJsonSubsetOf', { operator: '<@', bool: 'or' }),
|
|
677
|
-
args
|
|
677
|
+
args,
|
|
678
678
|
);
|
|
679
679
|
}
|
|
680
680
|
|
|
@@ -685,7 +685,7 @@ class QueryBuilderBase extends QueryBuilderOperationSupport {
|
|
|
685
685
|
bool: 'and',
|
|
686
686
|
prefix: 'not',
|
|
687
687
|
}),
|
|
688
|
-
args
|
|
688
|
+
args,
|
|
689
689
|
);
|
|
690
690
|
}
|
|
691
691
|
|
|
@@ -700,7 +700,7 @@ class QueryBuilderBase extends QueryBuilderOperationSupport {
|
|
|
700
700
|
bool: 'or',
|
|
701
701
|
prefix: 'not',
|
|
702
702
|
}),
|
|
703
|
-
args
|
|
703
|
+
args,
|
|
704
704
|
);
|
|
705
705
|
}
|
|
706
706
|
|
|
@@ -710,7 +710,7 @@ class QueryBuilderBase extends QueryBuilderOperationSupport {
|
|
|
710
710
|
bool: 'and',
|
|
711
711
|
compareValue: [],
|
|
712
712
|
}),
|
|
713
|
-
args
|
|
713
|
+
args,
|
|
714
714
|
);
|
|
715
715
|
}
|
|
716
716
|
|
|
@@ -720,7 +720,7 @@ class QueryBuilderBase extends QueryBuilderOperationSupport {
|
|
|
720
720
|
bool: 'or',
|
|
721
721
|
compareValue: [],
|
|
722
722
|
}),
|
|
723
|
-
args
|
|
723
|
+
args,
|
|
724
724
|
);
|
|
725
725
|
}
|
|
726
726
|
|
|
@@ -730,7 +730,7 @@ class QueryBuilderBase extends QueryBuilderOperationSupport {
|
|
|
730
730
|
bool: 'and',
|
|
731
731
|
compareValue: {},
|
|
732
732
|
}),
|
|
733
|
-
args
|
|
733
|
+
args,
|
|
734
734
|
);
|
|
735
735
|
}
|
|
736
736
|
|
|
@@ -740,35 +740,35 @@ class QueryBuilderBase extends QueryBuilderOperationSupport {
|
|
|
740
740
|
bool: 'or',
|
|
741
741
|
compareValue: {},
|
|
742
742
|
}),
|
|
743
|
-
args
|
|
743
|
+
args,
|
|
744
744
|
);
|
|
745
745
|
}
|
|
746
746
|
|
|
747
747
|
whereJsonHasAny(...args) {
|
|
748
748
|
return this.addOperation(
|
|
749
749
|
new WhereJsonHasPostgresOperation('whereJsonHasAny', { bool: 'and', operator: '?|' }),
|
|
750
|
-
args
|
|
750
|
+
args,
|
|
751
751
|
);
|
|
752
752
|
}
|
|
753
753
|
|
|
754
754
|
orWhereJsonHasAny(...args) {
|
|
755
755
|
return this.addOperation(
|
|
756
756
|
new WhereJsonHasPostgresOperation('orWhereJsonHasAny', { bool: 'or', operator: '?|' }),
|
|
757
|
-
args
|
|
757
|
+
args,
|
|
758
758
|
);
|
|
759
759
|
}
|
|
760
760
|
|
|
761
761
|
whereJsonHasAll(...args) {
|
|
762
762
|
return this.addOperation(
|
|
763
763
|
new WhereJsonHasPostgresOperation('whereJsonHasAll', { bool: 'and', operator: '?&' }),
|
|
764
|
-
args
|
|
764
|
+
args,
|
|
765
765
|
);
|
|
766
766
|
}
|
|
767
767
|
|
|
768
768
|
orWhereJsonHasAll(...args) {
|
|
769
769
|
return this.addOperation(
|
|
770
770
|
new WhereJsonHasPostgresOperation('orWhereJsonHasAll', { bool: 'or', operator: '?&' }),
|
|
771
|
-
args
|
|
771
|
+
args,
|
|
772
772
|
);
|
|
773
773
|
}
|
|
774
774
|
|
|
@@ -207,7 +207,7 @@ class QueryBuilderOperationSupport {
|
|
|
207
207
|
|
|
208
208
|
if (!knex) {
|
|
209
209
|
throw new Error(
|
|
210
|
-
`no database connection available for a query. You need to bind the model class or the query to a knex instance
|
|
210
|
+
`no database connection available for a query. You need to bind the model class or the query to a knex instance.`,
|
|
211
211
|
);
|
|
212
212
|
}
|
|
213
213
|
|
|
@@ -255,7 +255,7 @@ class QueryBuilderOperationSupport {
|
|
|
255
255
|
} else {
|
|
256
256
|
operationsToReplace.push({ op, findOp });
|
|
257
257
|
}
|
|
258
|
-
}
|
|
258
|
+
},
|
|
259
259
|
);
|
|
260
260
|
|
|
261
261
|
for (const op of operationsToRemove) {
|
|
@@ -364,7 +364,7 @@ class QueryBuilderOperationSupport {
|
|
|
364
364
|
every = false;
|
|
365
365
|
return false;
|
|
366
366
|
},
|
|
367
|
-
false
|
|
367
|
+
false,
|
|
368
368
|
);
|
|
369
369
|
|
|
370
370
|
return every;
|
|
@@ -76,8 +76,8 @@ class ReferenceBuilder {
|
|
|
76
76
|
const table = this.tableName
|
|
77
77
|
? this.tableName
|
|
78
78
|
: this.modelClass
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
? builder.tableRefFor(this.modelClass)
|
|
80
|
+
: null;
|
|
81
81
|
|
|
82
82
|
if (table) {
|
|
83
83
|
return `${table}.${this.column}`;
|
|
@@ -179,7 +179,7 @@ class GraphOptions {
|
|
|
179
179
|
return false;
|
|
180
180
|
} else {
|
|
181
181
|
throw new Error(
|
|
182
|
-
`expected ${optionName} option value "${option}" to be an instance of boolean or array of strings
|
|
182
|
+
`expected ${optionName} option value "${option}" to be an instance of boolean or array of strings`,
|
|
183
183
|
);
|
|
184
184
|
}
|
|
185
185
|
}
|
|
@@ -152,7 +152,7 @@ function findRoots(nodes) {
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
return true;
|
|
155
|
-
})
|
|
155
|
+
}),
|
|
156
156
|
);
|
|
157
157
|
}
|
|
158
158
|
|
|
@@ -160,8 +160,8 @@ function removeBranchesFromGraph(branchRoots, graph) {
|
|
|
160
160
|
const nodesToRemove = new Set(
|
|
161
161
|
branchRoots.reduce(
|
|
162
162
|
(nodesToRemove, node) => [...nodesToRemove, ...node.descendantRelationNodes],
|
|
163
|
-
[]
|
|
164
|
-
)
|
|
163
|
+
[],
|
|
164
|
+
),
|
|
165
165
|
);
|
|
166
166
|
|
|
167
167
|
removeNodesFromGraph(nodesToRemove, graph);
|
|
@@ -268,7 +268,7 @@ function checkForHasManyRelateErrors(graphData) {
|
|
|
268
268
|
node.parentEdge.relation.isObjectionHasManyRelation
|
|
269
269
|
) {
|
|
270
270
|
throw new Error(
|
|
271
|
-
'You cannot relate HasManyRelation or HasOneRelation using insertGraph, because those require update operations. Consider using upsertGraph instead.'
|
|
271
|
+
'You cannot relate HasManyRelation or HasOneRelation using insertGraph, because those require update operations. Consider using upsertGraph instead.',
|
|
272
272
|
);
|
|
273
273
|
}
|
|
274
274
|
}
|
|
@@ -292,7 +292,7 @@ function executeOperations(builder) {
|
|
|
292
292
|
function executeActions(builder, actions) {
|
|
293
293
|
return actions.reduce(
|
|
294
294
|
(promise, action) => promise.then(() => action.run(builder)),
|
|
295
|
-
Promise.resolve()
|
|
295
|
+
Promise.resolve(),
|
|
296
296
|
);
|
|
297
297
|
}
|
|
298
298
|
|
|
@@ -8,7 +8,7 @@ class GraphDelete extends GraphOperation {
|
|
|
8
8
|
return [
|
|
9
9
|
new GraphDeleteAction(this.graphData, {
|
|
10
10
|
nodes: this.currentGraph.nodes.filter((currentNode) =>
|
|
11
|
-
this.graphOptions.shouldDeleteOrUnrelate(currentNode, this.graphData)
|
|
11
|
+
this.graphOptions.shouldDeleteOrUnrelate(currentNode, this.graphData),
|
|
12
12
|
),
|
|
13
13
|
}),
|
|
14
14
|
];
|
|
@@ -50,7 +50,7 @@ class JoinRowGraphInsertAction extends GraphAction {
|
|
|
50
50
|
this._resolveReferences(node);
|
|
51
51
|
|
|
52
52
|
return joinTableModelClass.fromJson(
|
|
53
|
-
relation.createJoinModel(relation.ownerProp.getProps(parentNode.obj), node.obj)
|
|
53
|
+
relation.createJoinModel(relation.ownerProp.getProps(parentNode.obj), node.obj),
|
|
54
54
|
);
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -64,12 +64,12 @@ class JoinRowGraphInsertAction extends GraphAction {
|
|
|
64
64
|
if (node.parentEdge) {
|
|
65
65
|
return node.parentEdge.relation.joinTableBeforeInsert(
|
|
66
66
|
joinTableObj,
|
|
67
|
-
parentBuilder.context()
|
|
67
|
+
parentBuilder.context(),
|
|
68
68
|
);
|
|
69
69
|
} else {
|
|
70
70
|
return null;
|
|
71
71
|
}
|
|
72
|
-
})
|
|
72
|
+
}),
|
|
73
73
|
);
|
|
74
74
|
}
|
|
75
75
|
|
|
@@ -8,7 +8,7 @@ class GraphPatch extends GraphOperation {
|
|
|
8
8
|
return [
|
|
9
9
|
new GraphPatchAction(this.graphData, {
|
|
10
10
|
nodes: this.graph.nodes.filter((node) =>
|
|
11
|
-
this.graphOptions.shouldPatchOrUpdateIgnoreDisable(node, this.graphData)
|
|
11
|
+
this.graphOptions.shouldPatchOrUpdateIgnoreDisable(node, this.graphData),
|
|
12
12
|
),
|
|
13
13
|
}),
|
|
14
14
|
];
|
|
@@ -42,7 +42,7 @@ class GraphPatchAction extends GraphAction {
|
|
|
42
42
|
|
|
43
43
|
// Remove id properties from the props to update. With upsertGraph
|
|
44
44
|
// it never makes sense to change the id.
|
|
45
|
-
node.modelClass.getIdPropertyArray()
|
|
45
|
+
node.modelClass.getIdPropertyArray(),
|
|
46
46
|
);
|
|
47
47
|
|
|
48
48
|
const update = propsToUpdate.length > 0;
|
|
@@ -40,8 +40,8 @@ class GraphRecursiveUpsertAction extends GraphAction {
|
|
|
40
40
|
.copyFrom(parentBuilder, GraphAction.ReturningAllSelector)
|
|
41
41
|
.upsertGraph(
|
|
42
42
|
nodes.map((node) => node.obj),
|
|
43
|
-
this.graphOptions.rebasedOptions(nodes[0])
|
|
44
|
-
)
|
|
43
|
+
this.graphOptions.rebasedOptions(nodes[0]),
|
|
44
|
+
),
|
|
45
45
|
);
|
|
46
46
|
});
|
|
47
47
|
});
|
|
@@ -95,7 +95,7 @@ class JoinResultParser {
|
|
|
95
95
|
|
|
96
96
|
_createColumns(row) {
|
|
97
97
|
const columns = Object.keys(row).map((columnAlias) =>
|
|
98
|
-
JoinResultColumn.create({ tableTree: this.tableTree, columnAlias })
|
|
98
|
+
JoinResultColumn.create({ tableTree: this.tableTree, columnAlias }),
|
|
99
99
|
);
|
|
100
100
|
|
|
101
101
|
return groupBy(columns, getTableNode);
|
|
@@ -64,7 +64,7 @@ class RelationJoiner {
|
|
|
64
64
|
(modelClass) => modelClass.fetchTableMetadata({ parentBuilder: builder }),
|
|
65
65
|
{
|
|
66
66
|
concurrency: this.rootModelClass.getConcurrency(builder.unsafeKnex()),
|
|
67
|
-
}
|
|
67
|
+
},
|
|
68
68
|
);
|
|
69
69
|
}
|
|
70
70
|
|
|
@@ -204,7 +204,7 @@ function ensureIdAndRelationPropsAreSelected({ builder, tableNode }) {
|
|
|
204
204
|
...tableNode.relation.relatedProp.cols,
|
|
205
205
|
...tableNode.childNodes.reduce(
|
|
206
206
|
(cols, childNode) => [...cols, ...childNode.relation.ownerProp.cols],
|
|
207
|
-
[]
|
|
207
|
+
[],
|
|
208
208
|
),
|
|
209
209
|
];
|
|
210
210
|
|
|
@@ -264,7 +264,7 @@ function mapUserSelectionsFromSubqueryToMainQuery({ userSelections, tableNode })
|
|
|
264
264
|
return new Selection(
|
|
265
265
|
tableNode.alias,
|
|
266
266
|
selection.name,
|
|
267
|
-
tableNode.getColumnAliasForColumn(selection.name)
|
|
267
|
+
tableNode.getColumnAliasForColumn(selection.name),
|
|
268
268
|
);
|
|
269
269
|
});
|
|
270
270
|
}
|
|
@@ -274,7 +274,7 @@ function getJoinTableExtraSelectionsForNode({ builder, tableNode }) {
|
|
|
274
274
|
return new Selection(
|
|
275
275
|
tableNode.getJoinTableAlias(builder),
|
|
276
276
|
extra.joinTableCol,
|
|
277
|
-
tableNode.getColumnAliasForColumn(extra.aliasCol)
|
|
277
|
+
tableNode.getColumnAliasForColumn(extra.aliasCol),
|
|
278
278
|
);
|
|
279
279
|
});
|
|
280
280
|
}
|
|
@@ -285,7 +285,7 @@ function getAllColumnSelectionsForNode({ builder, tableNode }) {
|
|
|
285
285
|
|
|
286
286
|
if (!tableMeta) {
|
|
287
287
|
throw new Error(
|
|
288
|
-
`table metadata has not been fetched for table '${table}'. Are you trying to call toKnexQuery() for a withGraphJoined query? To make sure the table metadata is fetched see the objection.initialize function
|
|
288
|
+
`table metadata has not been fetched for table '${table}'. Are you trying to call toKnexQuery() for a withGraphJoined query? To make sure the table metadata is fetched see the objection.initialize function.`,
|
|
289
289
|
);
|
|
290
290
|
}
|
|
291
291
|
|
|
@@ -293,7 +293,7 @@ function getAllColumnSelectionsForNode({ builder, tableNode }) {
|
|
|
293
293
|
return new Selection(
|
|
294
294
|
tableNode.alias,
|
|
295
295
|
columnName,
|
|
296
|
-
tableNode.getColumnAliasForColumn(columnName)
|
|
296
|
+
tableNode.getColumnAliasForColumn(columnName),
|
|
297
297
|
);
|
|
298
298
|
});
|
|
299
299
|
}
|
|
@@ -303,7 +303,7 @@ function getIdSelectionsForNode({ tableNode }) {
|
|
|
303
303
|
return new Selection(
|
|
304
304
|
tableNode.alias,
|
|
305
305
|
columnName,
|
|
306
|
-
tableNode.getColumnAliasForColumn(columnName)
|
|
306
|
+
tableNode.getColumnAliasForColumn(columnName),
|
|
307
307
|
);
|
|
308
308
|
});
|
|
309
309
|
}
|
|
@@ -92,7 +92,7 @@ function parseTableAndAliasFromObject(arg, builder) {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
throw new Error(
|
|
95
|
-
`one of the tables in ${JSON.stringify(arg)} must be the query's model class's table
|
|
95
|
+
`one of the tables in ${JSON.stringify(arg)} must be the query's model class's table.`,
|
|
96
96
|
);
|
|
97
97
|
}
|
|
98
98
|
|
|
@@ -42,7 +42,7 @@ function shouldBeAdded(opName, builder, args) {
|
|
|
42
42
|
return false;
|
|
43
43
|
} else {
|
|
44
44
|
throw new Error(
|
|
45
|
-
`undefined passed as argument #${i} for '${opName}' operation. Call skipUndefined() method to ignore the undefined values
|
|
45
|
+
`undefined passed as argument #${i} for '${opName}' operation. Call skipUndefined() method to ignore the undefined values.`,
|
|
46
46
|
);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -103,7 +103,7 @@ function convertArray(arr, builder, i, opName, skipUndefined) {
|
|
|
103
103
|
if (item === undefined) {
|
|
104
104
|
if (!skipUndefined) {
|
|
105
105
|
throw new Error(
|
|
106
|
-
`undefined passed as an item in argument #${i} for '${opName}' operation. Call skipUndefined() method to ignore the undefined values
|
|
106
|
+
`undefined passed as an item in argument #${i} for '${opName}' operation. Call skipUndefined() method to ignore the undefined values.`,
|
|
107
107
|
);
|
|
108
108
|
}
|
|
109
109
|
} else if (hasToKnexRawMethod(item)) {
|
|
@@ -162,7 +162,7 @@ function convertPlainObject(obj, builder, i, opName, skipUndefined) {
|
|
|
162
162
|
if (item === undefined) {
|
|
163
163
|
if (!skipUndefined) {
|
|
164
164
|
throw new Error(
|
|
165
|
-
`undefined passed as a property in argument #${i} for '${opName}' operation. Call skipUndefined() method to ignore the undefined values
|
|
165
|
+
`undefined passed as a property in argument #${i} for '${opName}' operation. Call skipUndefined() method to ignore the undefined values.`,
|
|
166
166
|
);
|
|
167
167
|
}
|
|
168
168
|
} else if (hasToKnexRawMethod(item)) {
|
|
@@ -115,7 +115,7 @@ function convertFieldExpressionsToRaw(builder, model, json) {
|
|
|
115
115
|
|
|
116
116
|
convertedJson[parsed.column] = knex.raw(
|
|
117
117
|
`jsonb_set(??, '${jsonRefs}', ${valuePlaceholder}, true)`,
|
|
118
|
-
[convertedJson[parsed.column] || parsed.column, val]
|
|
118
|
+
[convertedJson[parsed.column] || parsed.column, val],
|
|
119
119
|
);
|
|
120
120
|
|
|
121
121
|
delete model[key];
|