mythix-orm 1.10.2 → 1.11.0

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.
@@ -238,7 +238,7 @@ class ConnectionBase extends EventEmitter {
238
238
  get: () => {
239
239
  return this.constructor.dialect;
240
240
  },
241
- set: () => {
241
+ set: () => {
242
242
  },
243
243
  },
244
244
  '_models': {
@@ -346,25 +346,6 @@ class ConnectionBase extends EventEmitter {
346
346
  /// are also valid return values (in which case no order will be
347
347
  /// applied to the given operation).
348
348
  getDefaultOrder(Model, options) {
349
- let order = Model.defaultOrder(options);
350
- if (!order)
351
- return;
352
-
353
- order = Nife.arrayFlatten(Nife.toArray(order)).filter((value) => {
354
- if (!value)
355
- return false;
356
-
357
- if (!Nife.instanceOf(value, 'string'))
358
- return false;
359
-
360
- return true;
361
- });
362
-
363
- if (Nife.isEmpty(order))
364
- return;
365
-
366
- let modelName = Model.getModelName();
367
- return order.map((value) => ((value.indexOf(':') < 0) ? `${modelName}:${value}` : value));
368
349
  }
369
350
 
370
351
  /// This method is called (and often provided)
@@ -396,6 +377,9 @@ class ConnectionBase extends EventEmitter {
396
377
  if (options.isSubQuery) {
397
378
  let subQueryOperator = options.subQueryOperator;
398
379
  if (subQueryOperator === 'EXISTS' || subQueryOperator === 'NOT EXISTS')
380
+ return false;
381
+
382
+ if (subQueryOperator === 'ANY' || subQueryOperator === 'ALL')
399
383
  return true;
400
384
 
401
385
  return 'PROJECTION_ONLY';
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const ModelUtils = require('../../utils/model-utils');
4
+ const Field = require('../../field');
4
5
 
5
6
  class LiteralBase {
6
7
  static _isMythixLiteral = true;
@@ -31,6 +32,13 @@ class LiteralBase {
31
32
  return false;
32
33
  }
33
34
 
35
+ isLiteral(value) {
36
+ if (arguments.length === 0)
37
+ return true;
38
+
39
+ return this.constructor.isLiteral(value);
40
+ }
41
+
34
42
  static isLiteralType(value) {
35
43
  return (this.isLiteral(value) && value.constructor && value.constructor.name === this.name);
36
44
  }
@@ -80,8 +88,19 @@ class LiteralBase {
80
88
  return definition;
81
89
 
82
90
  let field = connection.getField(definition.fieldNames[0], definition.modelName);
83
- if (!field)
91
+ if (!field) {
92
+ if (definition.fieldNames[0] && definition.modelName) {
93
+ let Model = connection.getModel(definition.modelName);
94
+ if (Model) {
95
+ return new Field({
96
+ fieldName: definition.fieldNames[0],
97
+ Model,
98
+ });
99
+ }
100
+ }
101
+
84
102
  throw new Error(`${this.constructor.name}::definitionToField: Unable to locate field "${definition.modelName}"."${definition.fieldNames[0]}".`);
103
+ }
85
104
 
86
105
  return field;
87
106
  }
@@ -69,7 +69,6 @@ export declare interface FieldOrderInfo {
69
69
  declare class QueryGeneratorBase {
70
70
  public constructor(connection);
71
71
  public stackAssign(obj: GenericObject, ...args: Array<GenericObject>): GenericObject;
72
- public getOptionsCache(options: GenericObject, keyPath: string, initialValue: any): any;
73
72
  public setOptionsCache(options: GenericObject, keyPath: string, value: any): void;
74
73
  public escape(field: Field, value: any, options?: GenericObject): string;
75
74
  public escapeID(value: LiteralBase | string, options?: GenericObject): string;
@@ -77,11 +76,7 @@ declare class QueryGeneratorBase {
77
76
  public getEscapedColumnName(Model: ModelClass | null | undefined, field: Field, options?: GetEscapedColumnNameOptions): string;
78
77
  public getEscapedTableName(modelOrField: ModelClass | Field, options?: GetEscapedTableNameNameOptions): string;
79
78
  public getEscapedProjectionName(Model: ModelClass | null | undefined, field: Field, options?: GetEscapedProjectionNameOptions): string;
80
- public getEscapedModelFields(Model: ModelClass, options?: GetEscapedModelFieldsOptions): { [ key: string ]: string };
81
- public getAllModelsUsedInQuery(queryEngine: QueryEngine, options?: GenericObject): Array<ModelClass>;
82
- public getProjectionRequiredFields(queryEngine: QueryEngine, options?: GenericObject): Map<string, ProjectedFieldInfo>;
83
- public sortedProjectedFields(projectedFields: Array<LiteralBase | string>, options?: GenericObject): Array<LiteralBase | string>;
84
- public getProjectionFromQueryEngine(queryEngine: QueryEngine, options?: GenericObject): Array<LiteralBase | string | ProjectedFieldInfo>;
79
+ public getEscapedModelFields(Model: ModelClass, options?: GetEscapedModelFieldsOptions): { [key: string]: string };
85
80
  public isFieldIdentifier(value: string): boolean;
86
81
  public getProjectedFields(queryEngine: QueryEngine, options?: GenericObject, asMap?: false | undefined): Array<string>;
87
82
  public getProjectedFields(queryEngine: QueryEngine, options?: GenericObject, asMap?: true): Map<string, string>;
@@ -96,15 +91,6 @@ declare class QueryGeneratorBase {
96
91
  public getFieldDirectionSpecifier(order: LiteralBase): LiteralBase;
97
92
  public getFieldDirectionSpecifier(order: string | Field): FieldDirectionInfo;
98
93
 
99
- public getOrderLimitOffset(
100
- queryEngine: QueryEngine,
101
- options?: GenericObject,
102
- ): {
103
- limit: number | undefined,
104
- offset: number | undefined,
105
- order: Array<FieldOrderInfo>,
106
- };
107
-
108
94
  public getQuerySliceFromQueryPart(queryPart: GenericObject): Array<GenericObject>;
109
95
  public _averageLiteralToString(literal: AverageLiteral, options?: GenericObject): string;
110
96
  public _countLiteralToString(literal: CountLiteral, options?: GenericObject): string;