mythix-orm-sql-base 1.10.0 → 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.
@@ -39,7 +39,7 @@ class SQLConnectionBase extends ConnectionBase {
39
39
  /// Note:
40
40
  /// This method escapes "values" that are given in
41
41
  /// the underlying query language of the database.
42
- /// To escape identifiers, use the <see>ConnectionBase._escapeID</see>
42
+ /// To escape identifiers, use the [ConnectionBase._escapeID](https://github.com/th317erd/mythix-orm/wiki/ConnectionBase#method-_escapeID)
43
43
  /// instead.
44
44
  ///
45
45
  /// Return: string
@@ -133,16 +133,19 @@ class SQLConnectionBase extends ConnectionBase {
133
133
  return `SP${id}`;
134
134
  }
135
135
 
136
- /// Given a `Map` from a projection field-set, find all matching
136
+ /// Given a `Map` or an `Array` from a projection field-set, find all matching
137
137
  /// projected fields through this connection, and return
138
138
  /// them as an array.
139
139
  ///
140
140
  /// Arguments:
141
- /// projectionFieldMap: Map<string, string>
142
- /// A set of projected fields, as a `Map`. This `Map` will usually be generated
141
+ /// projectionFieldMap: Map<string, string> | Array<string>
142
+ /// A set of projected fields, as a `Map` or an `Array`. A `Map` type will usually be generated
143
143
  /// by <see>SQLQueryGeneratorBase.getProjectedFields</see>. The `Map` is expected
144
144
  /// to have fully qualified field names and expanded literal strings as keys, with
145
- /// the projected database field (or literal) in database format for values.
145
+ /// the projected database fields (or literals) in database format for values. As
146
+ /// an `Array` type, this should be a list of fully qualified field names, or expanded
147
+ /// literals as values. An `Array` of field names is generally used when the `columns`
148
+ /// from the database result are passed into this method.
146
149
  ///
147
150
  /// Return: Array<[Field](https://github.com/th317erd/mythix-orm/wiki/Field) | string>
148
151
  /// All fields found from the projection `Map`. Any field that wasn't able to be
@@ -845,6 +848,10 @@ class SQLConnectionBase extends ConnectionBase {
845
848
 
846
849
  let batchSize = options.batchSize || 500;
847
850
  let startIndex = queryContext.offset || 0;
851
+ let limit = queryContext.limit;
852
+
853
+ if (Nife.instanceOf(limit, 'number') && isFinite(limit) && limit < batchSize)
854
+ batchSize = limit;
848
855
 
849
856
  while (true) {
850
857
  let query = queryEngine.clone().LIMIT(batchSize).OFFSET(startIndex);
@@ -55,7 +55,6 @@ declare class SQLQueryGeneratorBase extends QueryGeneratorBase {
55
55
  public getEscapedTableName(modelOrField: ModelClass | Field, options?: GetEscapedTableNameNameOptions): string;
56
56
  public getEscapedProjectionName(Model: ModelClass | null | undefined, field: Field, options?: GetEscapedProjectionNameOptions): string;
57
57
  public getEscapedModelFields(Model: ModelClass, options?: GetEscapedModelFieldsOptions): { [key: string]: string };
58
- public isFieldIdentifier(value: string): boolean;
59
58
  public getProjectedFields(queryEngine: QueryEngine, options?: GenericObject, asMap?: false | undefined): Array<string>;
60
59
  public getProjectedFields(queryEngine: QueryEngine, options?: GenericObject, asMap?: true): Map<string, string>;
61
60
 
@@ -67,21 +66,13 @@ declare class SQLQueryGeneratorBase extends QueryGeneratorBase {
67
66
  ): JoinTableInfo;
68
67
 
69
68
  public prepareArrayValuesForSQL(array: Array<any>): Array<any>;
70
- public parseFieldProjection(value: string, getRawField: boolean): string | Field | undefined;
71
- public parseFieldProjectionToFieldMap(selectStatement: string): Map<string, Field | string>;
72
69
 
73
70
  public generateSelectQueryFieldProjection(
74
71
  queryEngine: QueryEngine,
75
72
  options?: GenericObject,
76
- asMap?: false | undefined,
73
+ projectedFields?: Map<string, string>,
77
74
  ): Array<string>;
78
75
 
79
- public generateSelectQueryFieldProjection(
80
- queryEngine: QueryEngine,
81
- options?: GenericObject,
82
- asMap?: true,
83
- ): Map<string, string>;
84
-
85
76
  public generateSelectQueryOperatorFromQueryEngineOperator(
86
77
  queryPart: GenericObject,
87
78
  operator: string | LiteralBase,
@@ -174,7 +165,7 @@ declare class SQLQueryGeneratorBase extends QueryGeneratorBase {
174
165
 
175
166
  public generateInsertStatementTail(
176
167
  Model: ModelClass,
177
- model: Model,
168
+ models: Model | Array<Model> | PreparedModels,
178
169
  options: GenericObject,
179
170
  context: {
180
171
  escapedTableName: string,
@@ -225,9 +216,9 @@ declare class SQLQueryGeneratorBase extends QueryGeneratorBase {
225
216
  public generateAddColumnStatement(field: Field, options?: GenericObject): string;
226
217
 
227
218
  public _collectRemoteReturningFields(Model: ModelClass): Array<string>;
228
- public _collectReturningFields(
219
+ public generateReturningClause(
229
220
  Model: ModelClass,
230
- model: Model,
221
+ models: Model | Array<Model> | PreparedModels,
231
222
  options: GenericObject,
232
223
  context: {
233
224
  escapedTableName: string,