objection 3.0.0-alpha.6 → 3.0.0-rc.1

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.
@@ -4,8 +4,6 @@ const { clone } = require('./modelClone');
4
4
  const { bindKnex } = require('./modelBindKnex');
5
5
  const { validate } = require('./modelValidate');
6
6
  const { isMsSql } = require('../utils/knexUtils');
7
- const { deprecate } = require('../utils/deprecate');
8
- const { omit, pick } = require('./modelFilter');
9
7
  const { visitModels } = require('./modelVisitor');
10
8
  const { hasId, getSetId } = require('./modelId');
11
9
  const { map: promiseMap } = require('../utils/promiseUtils');
@@ -79,11 +77,6 @@ class Model {
79
77
  }).for(this);
80
78
  }
81
79
 
82
- $loadRelated(relationExpression, modifiers, transaction) {
83
- deprecate('$loadRelated is deprected and will be removed in 3.0. Use $fetchGraph instead');
84
- return this.$fetchGraph(relationExpression, { transaction }).modifiers(modifiers);
85
- }
86
-
87
80
  $fetchGraph(relationExpression, options) {
88
81
  return this.constructor.fetchGraph(this, relationExpression, options);
89
82
  }
@@ -179,7 +172,7 @@ class Model {
179
172
  // Do nothing by default.
180
173
  }
181
174
 
182
- // TODO: Deprecate & remove in 3.0
175
+ // TODO: Deprecate & remove
183
176
  $afterGet(queryContext) {
184
177
  // Do nothing by default.
185
178
  }
@@ -196,16 +189,6 @@ class Model {
196
189
  // Do nothing by default.
197
190
  }
198
191
 
199
- $omit(...args) {
200
- deprecate('Model#$omit is deprected and will be removed in 3.0.');
201
- return omit(this, args);
202
- }
203
-
204
- $pick(...args) {
205
- deprecate('Model#$pick is deprected and will be removed in 3.0.');
206
- return pick(this, args);
207
- }
208
-
209
192
  $values(props) {
210
193
  return values(this, props);
211
194
  }
@@ -427,7 +410,7 @@ class Model {
427
410
  }
428
411
 
429
412
  static getModifiers() {
430
- return this.modifiers || this.namedFilters || {};
413
+ return this.modifiers || {};
431
414
  }
432
415
 
433
416
  static columnNameToPropertyName(columnName) {
@@ -503,22 +486,14 @@ class Model {
503
486
  }
504
487
 
505
488
  static getDefaultGraphOptions() {
506
- return this.defaultGraphOptions || this.defaultEagerOptions;
489
+ return this.defaultGraphOptions;
507
490
  }
508
491
 
509
492
  static getRelatedFindQueryMutates() {
510
- if (this.relatedFindQueryMutates) {
511
- deprecate('Model.relatedFindQueryMutates is deprected and will be removed in 3.0.');
512
- }
513
-
514
493
  return this.relatedFindQueryMutates;
515
494
  }
516
495
 
517
496
  static getRelatedInsertQueryMutates() {
518
- if (this.relatedInsertQueryMutates) {
519
- deprecate('Model.relatedInsertQueryMutates is deprected and will be removed in 3.0.');
520
- }
521
-
522
497
  return this.relatedInsertQueryMutates;
523
498
  }
524
499
 
@@ -662,11 +637,6 @@ class Model {
662
637
  return relation;
663
638
  }
664
639
 
665
- static loadRelated(models, expression, modifiers, transaction) {
666
- deprecate('loadRelated is deprected and will be removed in 3.0. Use fetchGraph instead');
667
- return this.fetchGraph(models, expression, { transaction }).modifiers(modifiers);
668
- }
669
-
670
640
  static fetchGraph($models, expression, options = {}) {
671
641
  return this.query(options.transaction)
672
642
  .resolve(this.ensureModelArray($models))
@@ -765,20 +735,12 @@ Model.virtualAttributes = null;
765
735
  Model.relationMappings = null;
766
736
  Model.modelPaths = [];
767
737
  Model.pickJsonSchemaProperties = false;
768
- // Deprecated.
769
- Model.defaultEagerAlgorithm = Model.WhereInEagerAlgorithm;
770
- // Deprecated.
771
- Model.defaultEagerOptions = Object.freeze({ minimize: false, separator: ':', aliases: {} });
772
738
  Model.defaultGraphOptions = null;
773
739
  Model.defaultFindOptions = Object.freeze({});
774
740
  Model.modifiers = null;
775
- // Deprecated.
776
- Model.namedFilters = null;
777
741
  Model.useLimitInFirst = false;
778
742
  Model.columnNameMappers = null;
779
- // Deprecated.
780
743
  Model.relatedFindQueryMutates = false;
781
- // Deprecated.
782
744
  Model.relatedInsertQueryMutates = false;
783
745
  Model.concurrency = null;
784
746
 
@@ -52,6 +52,10 @@ function fetchTableMetadata(
52
52
 
53
53
  modelClass[TABLE_METADATA].set(table, metadata);
54
54
  return metadata;
55
+ })
56
+ .catch((err) => {
57
+ modelClass[TABLE_METADATA].delete(table);
58
+ throw err;
55
59
  });
56
60
 
57
61
  modelClass[TABLE_METADATA].set(table, promise);
package/lib/objection.js CHANGED
@@ -29,9 +29,7 @@ const { ref } = require('./queryBuilder/ReferenceBuilder');
29
29
  const { val } = require('./queryBuilder/ValueBuilder');
30
30
  const { raw } = require('./queryBuilder/RawBuilder');
31
31
  const { fn } = require('./queryBuilder/FunctionBuilder');
32
-
33
32
  const { inherit } = require('../lib/utils/classUtils');
34
- const { deprecate } = require('../lib/utils/deprecate');
35
33
 
36
34
  // We need to wrap the classes, that people can inherit, with ES5 classes
37
35
  // so that babel is able to use ES5 inheritance. sigh... Maybe people
@@ -86,12 +84,6 @@ module.exports = {
86
84
  val,
87
85
  raw,
88
86
  fn,
89
-
90
- get lit() {
91
- deprecate('`lit` is deprecated. Use `val` instead. `lit` will be removed in 3.0');
92
- return val;
93
- },
94
-
95
87
  snakeCaseMappers,
96
88
  knexSnakeCaseMappers,
97
89
  knexIdentifierMapping,
@@ -3,7 +3,6 @@
3
3
  const { wrapError } = require('db-errors');
4
4
 
5
5
  const { raw } = require('./RawBuilder');
6
- const { deprecate } = require('../utils/deprecate');
7
6
  const { createModifier } = require('../utils/createModifier');
8
7
  const { ValidationErrorType } = require('../model/ValidationError');
9
8
  const { isObject, isString, isFunction, last, flatten } = require('../utils/objectUtils');
@@ -112,22 +111,6 @@ class QueryBuilder extends QueryBuilderBase {
112
111
  return this.fullIdColumnFor(this.modelClass());
113
112
  }
114
113
 
115
- applyModifier(...args) {
116
- deprecate(
117
- 'applyModifier is deprecated. Use the modify method instead. applyModifier will be removed in objection 3.0'
118
- );
119
-
120
- return this.modify(flatten(args));
121
- }
122
-
123
- applyFilter(...args) {
124
- deprecate(
125
- 'applyFilter is deprecated. Use the modify method instead. applyFilter will be removed in objection 3.0'
126
- );
127
-
128
- return this.modify(flatten(args));
129
- }
130
-
131
114
  modifiers(modifiers) {
132
115
  if (arguments.length === 0) {
133
116
  return { ...this._modifiers };
@@ -224,102 +207,6 @@ class QueryBuilder extends QueryBuilderBase {
224
207
  return this;
225
208
  }
226
209
 
227
- eagerAlgorithm(...args) {
228
- deprecate(
229
- '`QueryBuilder#eagerAlgorithm` method is deprecated. You should explicitly use either withGraphFetched or withGraphJoined methods. `eagerAlgoritm` method will be removed in 3.0'
230
- );
231
-
232
- return this._eagerAlgorithm(...args);
233
- }
234
-
235
- _eagerAlgorithm(algorithm, eagerOptions) {
236
- ensureEagerOperation(this, algorithm);
237
-
238
- if (eagerOptions) {
239
- this._eagerOptions(eagerOptions);
240
- }
241
-
242
- return this;
243
- }
244
-
245
- eager(...args) {
246
- deprecate(
247
- '`QueryBuilder#eager` method is deprecated. You should use the `withGraphFetched` method instead. `eager` method will be removed in 3.0'
248
- );
249
-
250
- return this._eager(...args);
251
- }
252
-
253
- _eager(exp, modifiers) {
254
- const eagerOp = ensureEagerOperation(this);
255
-
256
- eagerOp.expression = parseRelationExpression(this.modelClass(), exp);
257
- checkEager(this);
258
-
259
- if (modifiers) {
260
- this.clearModifiers().modifiers(modifiers);
261
- }
262
-
263
- return this;
264
- }
265
-
266
- joinEager(exp, modifiers) {
267
- deprecate(
268
- '`QueryBuilder#joinEager` method is deprecated. You should use the `withGraphJoined` method instead. `joinEager` method will be removed in 3.0'
269
- );
270
-
271
- return this._eagerAlgorithm(getJoinEagerAlgorithm(this))._eager(exp, modifiers);
272
- }
273
-
274
- naiveEager(exp, modifiers) {
275
- deprecate(
276
- '`QueryBuilder#naiveEager` method is deprecated. You should use the `withGraphFetched` method with the `maxBatchSize: 1` option instead. `naiveEager` method will be removed in 3.0'
277
- );
278
-
279
- return this._eagerAlgorithm(getNaiveEagerAlgorithm(this))._eager(exp, modifiers);
280
- }
281
-
282
- mergeEager(...args) {
283
- deprecate(
284
- '`QueryBuilder#mergeEager` method is deprecated. You should use the `withGraphFetched` method instead. `mergeEager` method will be removed in 3.0'
285
- );
286
-
287
- return this._mergeEager(...args);
288
- }
289
-
290
- _mergeEager(exp, modifiers) {
291
- const eagerOp = ensureEagerOperation(this);
292
-
293
- eagerOp.expression = eagerOp.expression.merge(parseRelationExpression(this.modelClass(), exp));
294
- checkEager(this);
295
-
296
- return this.modifiers(modifiers);
297
- }
298
-
299
- mergeJoinEager(exp, modifiers) {
300
- deprecate(
301
- '`QueryBuilder#mergeJoinEager` method is deprecated. You should use the `withGraphJoined` method instead. `mergeJoinEager` method will be removed in 3.0'
302
- );
303
-
304
- return this._eagerAlgorithm(this.modelClass().JoinEagerAlgorithm)._mergeEager(exp, modifiers);
305
- }
306
-
307
- mergeNaiveEager(exp, modifiers) {
308
- deprecate(
309
- '`QueryBuilder#mergeNaiveEager` method is deprecated. You should use the `withGraphFetched` method with the `maxBatchSize: 1` option instead. `mergeNaiveEager` method will be removed in 3.0'
310
- );
311
-
312
- return this._eagerAlgorithm(this.modelClass().NaiveEagerAlgorithm)._mergeEager(exp, modifiers);
313
- }
314
-
315
- allowEager(exp) {
316
- deprecate(
317
- '`QueryBuilder#allowEager` method is deprecated. You should use `allowGraph` instead. `allowEager` method will be removed in 3.0'
318
- );
319
-
320
- return this.clearAllowGraph().allowGraph(exp);
321
- }
322
-
323
210
  allowGraph(exp) {
324
211
  const currentExpr = this._allowedGraphExpression || RelationExpression.create();
325
212
 
@@ -335,22 +222,6 @@ class QueryBuilder extends QueryBuilderBase {
335
222
  return this._allowedGraphExpression;
336
223
  }
337
224
 
338
- mergeAllowEager(exp) {
339
- deprecate(
340
- '`QueryBuilder#mergeAllowEager` method is deprecated. You should use `allowGraph` instead. `mergeAllowEager` method will be removed in 3.0'
341
- );
342
-
343
- return this.allowGraph(exp);
344
- }
345
-
346
- eagerObject() {
347
- deprecate(
348
- '`QueryBuilder#eagerObject` method is deprecated. You should use `graphExpressionObject` instead. `eagerObject` method will be removed in 3.0'
349
- );
350
-
351
- return this.graphExpressionObject();
352
- }
353
-
354
225
  graphExpressionObject() {
355
226
  const eagerOp = this.findOperation(EagerOperation);
356
227
 
@@ -361,22 +232,6 @@ class QueryBuilder extends QueryBuilderBase {
361
232
  }
362
233
  }
363
234
 
364
- eagerModifiers() {
365
- deprecate(
366
- '`QueryBuilder#eagerModifiers` method is deprecated. You should use `modifiers` instead. `eagerModifiers` method will be removed in 3.0'
367
- );
368
-
369
- return this.modifiers();
370
- }
371
-
372
- eagerModifiersAtPath() {
373
- deprecate(
374
- '`QueryBuilder#eagerModifiersAtPath` method is deprecated. You should use `graphModifiersAtPath` instead. `eagerModifiersAtPath` method will be removed in 3.0'
375
- );
376
-
377
- return this.graphModifiersAtPath();
378
- }
379
-
380
235
  graphModifiersAtPath() {
381
236
  const eagerOp = this.findOperation(EagerOperation);
382
237
 
@@ -387,58 +242,12 @@ class QueryBuilder extends QueryBuilderBase {
387
242
  }
388
243
  }
389
244
 
390
- modifyEager(...args) {
391
- deprecate(
392
- '`QueryBuilder#modifyEager` method is deprecated. You should use `modifyGraph` instead. `modifyEager` method will be removed in 3.0'
393
- );
394
-
395
- return this.modifyGraph(...args);
396
- }
397
-
398
245
  modifyGraph(path, modifier) {
399
246
  const eagerOp = ensureEagerOperation(this);
400
247
  eagerOp.modifiersAtPath.push({ path, modifier });
401
248
  return this;
402
249
  }
403
250
 
404
- filterEager(...args) {
405
- deprecate(
406
- '`QueryBuilder#filterEager` method is deprecated. You should use `modifyGraph` instead. `filterEager` method will be removed in 3.0'
407
- );
408
-
409
- return this.modifyGraph(...args);
410
- }
411
-
412
- allowUpsert(exp) {
413
- deprecate(
414
- '`QueryBuilder#allowUpsert` method is deprecated. You should use `allowGraph` instead. `allowUpsert` method will be removed in 3.0'
415
- );
416
-
417
- return this.clearAllowGraph().allowGraph(exp);
418
- }
419
-
420
- allowInsert(exp) {
421
- deprecate(
422
- '`QueryBuilder#allowInsert` method is deprecated. You should use `allowGraph` instead. `allowInsert` method will be removed in 3.0'
423
- );
424
-
425
- return this.clearAllowGraph().allowGraph(exp);
426
- }
427
-
428
- eagerOptions(...args) {
429
- deprecate(
430
- '`QueryBuilder#eagerOptions` method is deprecated. You should use `withGraphFetched` or `withGraphJoined` and pass options in the second argument. `eagerOptions` method will be removed in 3.0'
431
- );
432
-
433
- return this._eagerOptions(...args);
434
- }
435
-
436
- _eagerOptions(opt) {
437
- const eagerOp = ensureEagerOperation(this);
438
- eagerOp.graphOptions = Object.assign({}, eagerOp.graphOptions, opt);
439
- return this;
440
- }
441
-
442
251
  findOptions(opt) {
443
252
  if (arguments.length !== 0) {
444
253
  this._findOperationOptions = Object.assign({}, this._findOperationOptions, opt);
@@ -491,14 +300,6 @@ class QueryBuilder extends QueryBuilderBase {
491
300
  return this.has(QueryBuilderBase.SelectSelector);
492
301
  }
493
302
 
494
- hasEager() {
495
- deprecate(
496
- `QueryBuilder#hasEager is deprecated. Use hasWithGraph instead. This method will be removed in version 3.0`
497
- );
498
-
499
- return this.hasWithGraph();
500
- }
501
-
502
303
  hasWithGraph() {
503
304
  const eagerOp = this.findOperation(EagerOperation);
504
305
  return !!eagerOp && !eagerOp.expression.isEmpty;
@@ -532,20 +333,6 @@ class QueryBuilder extends QueryBuilderBase {
532
333
  });
533
334
  }
534
335
 
535
- isFindQuery() {
536
- deprecate(
537
- `isFindQuery is deprecated. Use isFind instead. This method will be removed in version 2.0`
538
- );
539
- return this.isFind();
540
- }
541
-
542
- isEagerQuery() {
543
- deprecate(
544
- `isEagerQuery is deprecated. Use hasWithGraph instead. This method will be removed in version 2.0`
545
- );
546
- return this.hasEager();
547
- }
548
-
549
336
  toString() {
550
337
  return '[object QueryBuilder]';
551
338
  }
@@ -584,14 +371,6 @@ class QueryBuilder extends QueryBuilderBase {
584
371
  return builder;
585
372
  }
586
373
 
587
- clearEager() {
588
- deprecate(
589
- '`QueryBuilder#clearEager` method is deprecated. You should use `clearWithGraph` instead. `clearEager` method will be removed in 3.0'
590
- );
591
-
592
- return this.clearWithGraph();
593
- }
594
-
595
374
  clearWithGraph() {
596
375
  this.clear(EagerOperation);
597
376
  return this;
@@ -671,20 +450,6 @@ class QueryBuilder extends QueryBuilderBase {
671
450
  }
672
451
  }
673
452
 
674
- pluck(propertyName) {
675
- deprecate(`QueryBuilder#pluck is deprecated. This method will be removed in version 3.0`);
676
-
677
- return this.runAfter((result) => {
678
- if (Array.isArray(result)) {
679
- return result.map((it) => it && it[propertyName]);
680
- } else if (isObject(result)) {
681
- return result[propertyName];
682
- } else {
683
- return result;
684
- }
685
- });
686
- }
687
-
688
453
  throwIfNotFound(data = {}) {
689
454
  return this.runAfter((result) => {
690
455
  if (
@@ -776,47 +541,6 @@ class QueryBuilder extends QueryBuilderBase {
776
541
  });
777
542
  }
778
543
 
779
- pick(modelClass, properties) {
780
- deprecate(`QueryBuilder#pick is deprecated. This method will be removed in version 3.0`);
781
-
782
- if (typeof properties === 'undefined') {
783
- properties = modelClass;
784
- modelClass = null;
785
- }
786
-
787
- // Turn the properties into a hash for performance.
788
- properties = properties.reduce((obj, prop) => {
789
- obj[prop] = true;
790
- return obj;
791
- }, {});
792
-
793
- return this.traverse(modelClass, (model) => {
794
- model.$pick(properties);
795
- });
796
- }
797
-
798
- omit(modelClass, properties) {
799
- deprecate(`QueryBuilder#omit is deprecated. This method will be removed in version 3.0`);
800
-
801
- if (typeof properties === 'undefined') {
802
- properties = modelClass;
803
- modelClass = null;
804
- }
805
-
806
- if (Array.isArray(properties)) {
807
- // Turn the properties into a hash for performance.
808
- properties = properties.reduce((obj, prop) => {
809
- obj[prop] = true;
810
- return obj;
811
- }, {});
812
- } else {
813
- properties = { [properties]: true };
814
- }
815
- return this.traverse(modelClass, (model) => {
816
- model.$omit(properties);
817
- });
818
- }
819
-
820
544
  page(page, pageSize) {
821
545
  return this.range(+page * +pageSize, (+page + 1) * +pageSize - 1);
822
546
  }
@@ -897,13 +621,6 @@ class QueryBuilder extends QueryBuilderBase {
897
621
  });
898
622
  }
899
623
 
900
- insertWithRelated(...args) {
901
- deprecate(
902
- `insertWithRelated is deprecated. Use insertGraph instead. This method will be removed in version 2.0`
903
- );
904
- return this.insertGraph(...args);
905
- }
906
-
907
624
  insertGraphAndFetch(modelsOrObjects, opt) {
908
625
  return writeOperation(this, () => {
909
626
  const insertOperation = this._insertOperationFactory(this);
@@ -921,13 +638,6 @@ class QueryBuilder extends QueryBuilderBase {
921
638
  });
922
639
  }
923
640
 
924
- insertWithRelatedAndFetch(...args) {
925
- deprecate(
926
- `insertWithRelatedAndFetch is deprecated. Use insertGraphAndFetch instead. This method will be removed in version 2.0`
927
- );
928
- return this.insertGraphAndFetch(...args);
929
- }
930
-
931
641
  update(modelOrObject) {
932
642
  return writeOperation(this, () => {
933
643
  const updateOperation = this._updateOperationFactory(this);
@@ -1107,14 +817,6 @@ class QueryBuilder extends QueryBuilderBase {
1107
817
  return this;
1108
818
  }
1109
819
 
1110
- joinRelation(...args) {
1111
- deprecate(
1112
- `joinRelation is deprecated. Use joinRelated instead. This method will be removed in version 3.0`
1113
- );
1114
-
1115
- return this.joinRelated(...args);
1116
- }
1117
-
1118
820
  innerJoinRelated(expression, options) {
1119
821
  ensureJoinRelatedOperation(this, 'innerJoin').addCall({
1120
822
  expression,
@@ -1124,14 +826,6 @@ class QueryBuilder extends QueryBuilderBase {
1124
826
  return this;
1125
827
  }
1126
828
 
1127
- innerJoinRelation(...args) {
1128
- deprecate(
1129
- `innerJoinRelation is deprecated. Use innerJoinRelated instead. This method will be removed in version 3.0`
1130
- );
1131
-
1132
- return this.innerJoinRelated(...args);
1133
- }
1134
-
1135
829
  outerJoinRelated(expression, options) {
1136
830
  ensureJoinRelatedOperation(this, 'outerJoin').addCall({
1137
831
  expression,
@@ -1141,14 +835,6 @@ class QueryBuilder extends QueryBuilderBase {
1141
835
  return this;
1142
836
  }
1143
837
 
1144
- outerJoinRelation(...args) {
1145
- deprecate(
1146
- `outerJoinRelation is deprecated. Use outerJoinRelated instead. This method will be removed in version 3.0`
1147
- );
1148
-
1149
- return this.outerJoinRelated(...args);
1150
- }
1151
-
1152
838
  fullOuterJoinRelated(expression, options) {
1153
839
  ensureJoinRelatedOperation(this, 'fullOuterJoin').addCall({
1154
840
  expression,
@@ -1158,14 +844,6 @@ class QueryBuilder extends QueryBuilderBase {
1158
844
  return this;
1159
845
  }
1160
846
 
1161
- fullOuterJoinRelation(...args) {
1162
- deprecate(
1163
- `fullOuterJoinRelation is deprecated. Use fullOuterJoinRelated instead. This method will be removed in version 3.0`
1164
- );
1165
-
1166
- return this.fullOuterJoinRelated(...args);
1167
- }
1168
-
1169
847
  leftJoinRelated(expression, options) {
1170
848
  ensureJoinRelatedOperation(this, 'leftJoin').addCall({
1171
849
  expression,
@@ -1175,14 +853,6 @@ class QueryBuilder extends QueryBuilderBase {
1175
853
  return this;
1176
854
  }
1177
855
 
1178
- leftJoinRelation(...args) {
1179
- deprecate(
1180
- `leftJoinRelation is deprecated. Use leftJoinRelated instead. This method will be removed in version 3.0`
1181
- );
1182
-
1183
- return this.leftJoinRelated(...args);
1184
- }
1185
-
1186
856
  leftOuterJoinRelated(expression, options) {
1187
857
  ensureJoinRelatedOperation(this, 'leftOuterJoin').addCall({
1188
858
  expression,
@@ -1192,14 +862,6 @@ class QueryBuilder extends QueryBuilderBase {
1192
862
  return this;
1193
863
  }
1194
864
 
1195
- leftOuterJoinRelation(...args) {
1196
- deprecate(
1197
- `leftOuterJoinRelation is deprecated. Use leftOuterJoinRelated instead. This method will be removed in version 3.0`
1198
- );
1199
-
1200
- return this.leftOuterJoinRelated(...args);
1201
- }
1202
-
1203
865
  rightJoinRelated(expression, options) {
1204
866
  ensureJoinRelatedOperation(this, 'rightJoin').addCall({
1205
867
  expression,
@@ -1209,14 +871,6 @@ class QueryBuilder extends QueryBuilderBase {
1209
871
  return this;
1210
872
  }
1211
873
 
1212
- rightJoinRelation(...args) {
1213
- deprecate(
1214
- `rightJoinRelation is deprecated. Use rightJoinRelated instead. This method will be removed in version 3.0`
1215
- );
1216
-
1217
- return this.rightJoinRelated(...args);
1218
- }
1219
-
1220
874
  rightOuterJoinRelated(expression, options) {
1221
875
  ensureJoinRelatedOperation(this, 'rightOuterJoin').addCall({
1222
876
  expression,
@@ -1226,14 +880,6 @@ class QueryBuilder extends QueryBuilderBase {
1226
880
  return this;
1227
881
  }
1228
882
 
1229
- rightOuterJoinRelation(...args) {
1230
- deprecate(
1231
- `rightOuterJoinRelation is deprecated. Use rightOuterJoinRelated instead. This method will be removed in version 3.0`
1232
- );
1233
-
1234
- return this.rightOuterJoinRelated(...args);
1235
- }
1236
-
1237
883
  deleteById(id) {
1238
884
  return this.findById(id)
1239
885
  .delete()
@@ -1336,7 +982,7 @@ function ensureEagerOperation(builder, algorithm = null) {
1336
982
  } else {
1337
983
  const EagerOperationClass = getOperationClassForEagerAlgorithm(
1338
984
  builder,
1339
- getDefaultEagerAlgorithm(builder)
985
+ getWhereInEagerAlgorithm(builder)
1340
986
  );
1341
987
 
1342
988
  const newEagerOp = new EagerOperationClass('eager', {
@@ -1350,18 +996,6 @@ function ensureEagerOperation(builder, algorithm = null) {
1350
996
  }
1351
997
  }
1352
998
 
1353
- function getDefaultEagerAlgorithm(builder) {
1354
- const eagerAlgorithm = builder.modelClass().defaultEagerAlgorithm;
1355
-
1356
- if (eagerAlgorithm !== getWhereInEagerAlgorithm(builder)) {
1357
- deprecate(
1358
- 'Model.defaultEagerAlgorithm is deprecated. You need to use `withGraphFetched` or `withGraphJoined` explicitly. `defaultEagerAlgorithm` will be removed in 3.0'
1359
- );
1360
- }
1361
-
1362
- return eagerAlgorithm;
1363
- }
1364
-
1365
999
  function getWhereInEagerAlgorithm(builder) {
1366
1000
  return builder.modelClass().WhereInEagerAlgorithm;
1367
1001
  }
@@ -1,6 +1,5 @@
1
1
  'use strict';
2
2
 
3
- const { deprecate } = require('../utils/deprecate');
4
3
  const { isString, isFunction, isRegExp, last } = require('../utils/objectUtils');
5
4
  const { QueryBuilderContextBase } = require('./QueryBuilderContextBase');
6
5
  const { QueryBuilderUserContext } = require('./QueryBuilderUserContext');
@@ -83,14 +82,6 @@ class QueryBuilderOperationSupport {
83
82
  }
84
83
  }
85
84
 
86
- mergeContext(obj) {
87
- deprecate(
88
- '`QueryBuilder#mergeContext` method is deprecated. The `context` method now behaves just like `mergeContext`. `mergeContext` method will be removed in 3.0'
89
- );
90
-
91
- return this.context(obj || {});
92
- }
93
-
94
85
  clearContext() {
95
86
  const ctx = this._context;
96
87
  ctx.userContext = new this.constructor.QueryBuilderUserContext(this);
@@ -2,7 +2,6 @@
2
2
 
3
3
  const { parseFieldExpression } = require('../utils/parseFieldExpression');
4
4
  const { isObject } = require('../utils/objectUtils');
5
- const { deprecate } = require('../utils/deprecate');
6
5
 
7
6
  class ReferenceBuilder {
8
7
  constructor(expr) {
@@ -120,13 +119,6 @@ class ReferenceBuilder {
120
119
  return this;
121
120
  }
122
121
 
123
- castType(sqlType) {
124
- deprecate(
125
- 'castType(type) is deprecated. Use castTo(type) instead. castType(type) will be removed in 2.0'
126
- );
127
- return this.castTo(sqlType);
128
- }
129
-
130
122
  castTo(sqlType) {
131
123
  this._cast = sqlType;
132
124
  return this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "objection",
3
- "version": "3.0.0-alpha.6",
3
+ "version": "3.0.0-rc.1",
4
4
  "description": "An SQL-friendly ORM for Node.js",
5
5
  "main": "lib/objection.js",
6
6
  "license": "MIT",
@@ -8,10 +8,6 @@
8
8
  "test": "npm run eslint && mocha --slow 10 --timeout 15000 --reporter spec --recursive tests --exclude \"tests/unit/relations/files/**\"",
9
9
  "test-fast": "mocha --slow 10 --timeout 15000 --reporter spec --recursive tests --bail --exclude \"tests/unit/relations/files/**\"",
10
10
  "test-typings": "tsc",
11
- "coveralls": "cat ./testCoverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
12
- "perf": "mocha --slow 60000 --timeout 60000 --reporter spec --recursive perf",
13
- "perf-debug": "mocha --slow 60000 --timeout 60000 --reporter spec --inspect-brk perf",
14
- "perf-opt": "mocha --slow 60000 --timeout 60000 --reporter spec --recursive perf --trace_opt --trace_deopt",
15
11
  "prettier": "prettier --write \"{examples,lib,tests,typings,doc}/**/*.{js,ts}\"",
16
12
  "eslint": "eslint --format codeframe \"examples/**/*.js\" \"lib/**/*.js\" \"tests/**/*.js\"",
17
13
  "docs:dev": "vuepress dev doc",
@@ -64,38 +60,20 @@
64
60
  "knex": ">=0.95.0"
65
61
  },
66
62
  "devDependencies": {
67
- "@types/node": "^16.3.2",
63
+ "@types/node": "^16.11.6",
68
64
  "chai": "^4.3.4",
69
65
  "chai-subset": "^1.6.0",
70
- "coveralls": "^3.1.1",
71
- "cross-env": "^7.0.3",
72
- "eslint": "^7.30.0",
73
- "eslint-plugin-prettier": "^3.4.0",
66
+ "eslint": "^8.1.0",
67
+ "eslint-formatter-codeframe": "^7.32.1",
68
+ "eslint-plugin-prettier": "^4.0.0",
74
69
  "expect.js": "^0.3.1",
75
- "fs-extra": "^10.0.0",
76
- "glob": "^7.1.7",
77
- "knex": "0.95.7",
78
- "mocha": "^9.0.2",
70
+ "knex": "0.95.13",
71
+ "mocha": "^9.1.3",
79
72
  "mysql": "^2.18.1",
80
- "nyc": "^15.1.0",
81
- "pg": "^8.6.0",
82
- "prettier": "2.3.2",
73
+ "pg": "^8.7.1",
74
+ "prettier": "2.4.1",
83
75
  "sqlite3": "^5.0.2",
84
76
  "typescript": "^4.4.4",
85
77
  "vuepress": "1.8.2"
86
- },
87
- "nyc": {
88
- "description": "test coverage",
89
- "exclude": [
90
- "lib/queryBuilder/parsers/jsonFieldExpressionParser.js",
91
- "lib/queryBuilder/parsers/relationExpressionParser.js",
92
- "testUtils/*",
93
- "lib/utils/clone.js"
94
- ],
95
- "reporter": [
96
- "lcov",
97
- "text"
98
- ],
99
- "report-dir": "./testCoverage"
100
78
  }
101
79
  }
@@ -21,8 +21,6 @@ export = Objection;
21
21
 
22
22
  declare namespace Objection {
23
23
  const raw: RawFunction;
24
- // Deprecated
25
- const lit: ValueFunction;
26
24
  const val: ValueFunction;
27
25
  const ref: ReferenceFunction;
28
26
  const fn: FunctionFunction;
@@ -138,7 +136,7 @@ declare namespace Objection {
138
136
 
139
137
  type Expression<T> = T | Raw | ReferenceBuilder | ValueBuilder | AnyQueryBuilder;
140
138
 
141
- type Id = string | number;
139
+ type Id = string | number | BigInt;
142
140
  type CompositeId = Id[];
143
141
  type MaybeCompositeId = Id | CompositeId;
144
142
 
@@ -577,11 +575,6 @@ declare namespace Objection {
577
575
 
578
576
  type ForIdValue = MaybeCompositeId | AnyQueryBuilder;
579
577
 
580
- // Deprecated
581
- interface EagerMethod<QB extends AnyQueryBuilder> {
582
- (expr: RelationExpression<ModelType<QB>>, modifiers?: Modifiers): QB;
583
- }
584
-
585
578
  interface AllowGraphMethod<QB extends AnyQueryBuilder> {
586
579
  (expr: RelationExpression<ModelType<QB>>): QB;
587
580
  }
@@ -736,22 +729,6 @@ declare namespace Objection {
736
729
  (): any;
737
730
  }
738
731
 
739
- // Deprecated
740
- export interface EagerAlgorithm {}
741
-
742
- // Deprecated
743
- interface EagerAlgorithmMethod<QB extends AnyQueryBuilder> {
744
- (algorithm: EagerAlgorithm): QB;
745
- }
746
-
747
- // Deprecated
748
- export interface EagerOptions {
749
- minimize?: boolean;
750
- separator?: string;
751
- aliases?: string[];
752
- joinOperation: string;
753
- }
754
-
755
732
  export interface GraphOptions {
756
733
  minimize?: boolean;
757
734
  separator?: string;
@@ -760,11 +737,6 @@ declare namespace Objection {
760
737
  maxBatchSize?: number;
761
738
  }
762
739
 
763
- // Deprecated
764
- interface EagerOptionsMethod<QB extends AnyQueryBuilder> {
765
- (options: EagerOptions): QB;
766
- }
767
-
768
740
  interface ModifyGraphMethod<QB extends AnyQueryBuilder> {
769
741
  <M extends Model>(
770
742
  expr: RelationExpression<ModelType<QB>>,
@@ -790,11 +762,6 @@ declare namespace Objection {
790
762
  (): QB;
791
763
  }
792
764
 
793
- // Deprecated
794
- interface ApplyFilterMethod<QB extends AnyQueryBuilder> {
795
- (...filters: string[]): QB;
796
- }
797
-
798
765
  export interface Pojo {
799
766
  [key: string]: any;
800
767
  }
@@ -921,23 +888,6 @@ declare namespace Objection {
921
888
  withRecursive: WithMethod<this>;
922
889
  withWrapped: WithMethod<this>;
923
890
 
924
- // Deprecated
925
- joinRelation: JoinRelatedMethod<this>;
926
- // Deprecated
927
- innerJoinRelation: JoinRelatedMethod<this>;
928
- // Deprecated
929
- outerJoinRelation: JoinRelatedMethod<this>;
930
- // Deprecated
931
- leftJoinRelation: JoinRelatedMethod<this>;
932
- // Deprecated
933
- leftOuterJoinRelation: JoinRelatedMethod<this>;
934
- // Deprecated
935
- rightJoinRelation: JoinRelatedMethod<this>;
936
- // Deprecated
937
- rightOuterJoinRelation: JoinRelatedMethod<this>;
938
- // Deprecated
939
- fullOuterJoinRelation: JoinRelatedMethod<this>;
940
-
941
891
  joinRelated: JoinRelatedMethod<this>;
942
892
  innerJoinRelated: JoinRelatedMethod<this>;
943
893
  outerJoinRelated: JoinRelatedMethod<this>;
@@ -1027,32 +977,7 @@ declare namespace Objection {
1027
977
  withGraphJoined(expr: RelationExpression<M>, options?: GraphOptions): this;
1028
978
 
1029
979
  truncate(): Promise<void>;
1030
-
1031
- // Deprecated
1032
- eager: EagerMethod<this>;
1033
- // Deprecated
1034
- mergeEager: EagerMethod<this>;
1035
-
1036
- // Deprecated
1037
- joinEager: EagerMethod<this>;
1038
- // Deprecated
1039
- mergeJoinEager: EagerMethod<this>;
1040
-
1041
- // Deprecated
1042
- naiveEager: EagerMethod<this>;
1043
- // Deprecated
1044
- mergeNaiveEager: EagerMethod<this>;
1045
-
1046
- // Deprecated
1047
- allowEager: AllowGraphMethod<this>;
1048
- // Deprecated
1049
- mergeAllowEager: AllowGraphMethod<this>;
1050
-
1051
980
  allowGraph: AllowGraphMethod<this>;
1052
- // Deprecated
1053
- allowInsert: AllowGraphMethod<this>;
1054
- // Deprecated
1055
- allowUpsert: AllowGraphMethod<this>;
1056
981
 
1057
982
  throwIfNotFound: (
1058
983
  arg?: any
@@ -1081,17 +1006,6 @@ declare namespace Objection {
1081
1006
  toKnexQuery<T = ModelObject<M>>(): Knex.QueryBuilder<T, T[]>;
1082
1007
  clone(): this;
1083
1008
 
1084
- // Deprecated
1085
- pluck(property: string): this;
1086
- // Deprecated
1087
- pick(modelClass: typeof Model, properties: string[]): this;
1088
- // Deprecated
1089
- pick(properties: string[]): this;
1090
- // Deprecated
1091
- omit(modelClass: typeof Model, properties: string[]): this;
1092
- // Deprecated
1093
- omit(properties: string[]): this;
1094
-
1095
1009
  page(page: number, pageSize: number): PageQueryBuilder<this>;
1096
1010
  range(): PageQueryBuilder<this>;
1097
1011
  range(start: number, end: number): PageQueryBuilder<this>;
@@ -1108,33 +1022,19 @@ declare namespace Objection {
1108
1022
 
1109
1023
  insertGraph: InsertGraphMethod<M>;
1110
1024
  insertGraphAndFetch: InsertGraphMethod<M>;
1111
- insertWithRelated: InsertGraphMethod<M>;
1112
- insertWithRelatedAndFetch: InsertGraphMethod<M>;
1113
1025
 
1114
1026
  upsertGraph: UpsertGraphMethod<M>;
1115
1027
  upsertGraphAndFetch: UpsertGraphMethod<M>;
1116
1028
 
1117
1029
  graphExpressionObject: GraphExpressionObjectMethod<this>;
1118
1030
 
1119
- // Deprecated
1120
- eagerAlgorithm: EagerAlgorithmMethod<this>;
1121
- // Deprecated
1122
- eagerOptions: EagerOptionsMethod<this>;
1123
- // Deprecated
1124
- modifyEager: ModifyGraphMethod<this>;
1125
- // Deprecated
1126
- filterEager: ModifyGraphMethod<this>;
1127
1031
  modifyGraph: ModifyGraphMethod<this>;
1128
1032
 
1129
1033
  context: ContextMethod<this>;
1130
1034
  clearContext: ClearContextMethod<this>;
1131
- // Deprecated
1132
- mergeContext: ContextMethod<this>;
1133
1035
 
1134
1036
  modify: ModifyMethod<this>;
1135
1037
  modifiers: ModifiersMethod<this>;
1136
- // Deprecated
1137
- applyFilter: ApplyFilterMethod<this>;
1138
1038
 
1139
1039
  isFind: BooleanReturningMethod;
1140
1040
  isExecutable: BooleanReturningMethod;
@@ -1146,8 +1046,6 @@ declare namespace Objection {
1146
1046
  isInternal: BooleanReturningMethod;
1147
1047
  hasWheres: BooleanReturningMethod;
1148
1048
  hasSelects: BooleanReturningMethod;
1149
- // Deprecated
1150
- hasEager: BooleanReturningMethod;
1151
1049
  hasWithGraph: BooleanReturningMethod;
1152
1050
 
1153
1051
  has: HasMethod;
@@ -1158,8 +1056,6 @@ declare namespace Objection {
1158
1056
  clearWhere: IdentityMethod<this>;
1159
1057
  clearWithGraph: IdentityMethod<this>;
1160
1058
  clearAllowGraph: IdentityMethod<this>;
1161
- // Deprecated
1162
- clearEager: IdentityMethod<this>;
1163
1059
 
1164
1060
  ModelType: M;
1165
1061
  ResultType: R;
@@ -1444,17 +1340,6 @@ declare namespace Objection {
1444
1340
  HasOneThroughRelation: RelationType;
1445
1341
 
1446
1342
  defaultGraphOptions?: GraphOptions;
1447
- // Deprecated
1448
- defaultEagerAlgorithm?: EagerAlgorithm;
1449
- // Deprecated
1450
- defaultEagerOptions?: EagerOptions;
1451
-
1452
- // Deprecated
1453
- WhereInEagerAlgorithm: EagerAlgorithm;
1454
- // Deprecated
1455
- NaiveEagerAlgorithm: EagerAlgorithm;
1456
- // Deprecated
1457
- JoinEagerAlgorithm: EagerAlgorithm;
1458
1343
 
1459
1344
  query(this: Constructor<M>, trxOrKnex?: TransactionOrKnex): QueryBuilderType<M>;
1460
1345
 
@@ -1491,22 +1376,6 @@ declare namespace Objection {
1491
1376
  bindKnex(trxOrKnex: TransactionOrKnex): this;
1492
1377
  bindTransaction(trxOrKnex: TransactionOrKnex): this;
1493
1378
 
1494
- // Deprecated
1495
- loadRelated(
1496
- modelOrObject: PartialModelObject<M>,
1497
- expression: RelationExpression<M>,
1498
- modifiers?: Modifiers<QueryBuilderType<M>>,
1499
- trxOrKnex?: TransactionOrKnex
1500
- ): SingleQueryBuilder<QueryBuilderType<M>>;
1501
-
1502
- // Deprecated
1503
- loadRelated(
1504
- modelOrObject: PartialModelObject<M>[],
1505
- expression: RelationExpression<M>,
1506
- modifiers?: Modifiers<QueryBuilderType<M>>,
1507
- trxOrKnex?: TransactionOrKnex
1508
- ): QueryBuilderType<M>;
1509
-
1510
1379
  fetchGraph(
1511
1380
  modelOrObject: PartialModelObject<M>,
1512
1381
  expression: RelationExpression<M>,
@@ -1577,17 +1446,6 @@ declare namespace Objection {
1577
1446
  static HasOneThroughRelation: RelationType;
1578
1447
 
1579
1448
  static defaultGraphOptions?: GraphOptions;
1580
- // Deprecated
1581
- static defaultEagerAlgorithm?: EagerAlgorithm;
1582
- // Deprecated
1583
- static defaultEagerOptions?: EagerOptions;
1584
-
1585
- // Deprecated
1586
- static WhereInEagerAlgorithm: EagerAlgorithm;
1587
- // Deprecated
1588
- static NaiveEagerAlgorithm: EagerAlgorithm;
1589
- // Deprecated
1590
- static JoinEagerAlgorithm: EagerAlgorithm;
1591
1449
 
1592
1450
  static query<M extends Model>(
1593
1451
  this: Constructor<M>,
@@ -1628,24 +1486,6 @@ declare namespace Objection {
1628
1486
  static bindKnex<M>(this: M, trxOrKnex: TransactionOrKnex): M;
1629
1487
  static bindTransaction<M>(this: M, trxOrKnex: TransactionOrKnex): M;
1630
1488
 
1631
- // Deprecated
1632
- static loadRelated<M extends Model>(
1633
- this: Constructor<M>,
1634
- modelOrObject: PartialModelObject<M>,
1635
- expression: RelationExpression<M>,
1636
- modifiers?: Modifiers<QueryBuilderType<M>>,
1637
- trxOrKnex?: TransactionOrKnex
1638
- ): SingleQueryBuilder<QueryBuilderType<M>>;
1639
-
1640
- // Deprecated
1641
- static loadRelated<M extends Model>(
1642
- this: Constructor<M>,
1643
- modelOrObject: PartialModelObject<M>[],
1644
- expression: RelationExpression<M>,
1645
- modifiers?: Modifiers<QueryBuilderType<M>>,
1646
- trxOrKnex?: TransactionOrKnex
1647
- ): QueryBuilderType<M>;
1648
-
1649
1489
  static fetchGraph<M extends Model>(
1650
1490
  this: Constructor<M>,
1651
1491
  modelOrObject: PartialModelObject<M>,
@@ -1702,13 +1542,6 @@ declare namespace Objection {
1702
1542
  $id(id: any): void;
1703
1543
  $id(): any;
1704
1544
 
1705
- // Deprecated
1706
- $loadRelated(
1707
- expression: RelationExpression<this>,
1708
- modifiers?: Modifiers<QueryBuilderType<this>>,
1709
- trxOrKnex?: TransactionOrKnex
1710
- ): SingleQueryBuilder<QueryBuilderType<this>>;
1711
-
1712
1545
  $fetchGraph(
1713
1546
  expression: RelationExpression<this>,
1714
1547
  options?: FetchGraphOptions