@mikro-orm/knex 7.0.0-dev.75 → 7.0.0-dev.77

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.
@@ -112,7 +112,7 @@ export class AbstractSqlDriver extends DatabaseDriver {
112
112
  }
113
113
  async findFromVirtual(entityName, where, options, type) {
114
114
  const meta = this.metadata.get(entityName);
115
- /* v8 ignore next 3 */
115
+ /* v8 ignore next */
116
116
  if (!meta.expression) {
117
117
  return type === QueryType.SELECT ? [] : 0;
118
118
  }
@@ -132,12 +132,12 @@ export class AbstractSqlDriver extends DatabaseDriver {
132
132
  const expr = this.platform.formatQuery(res.sql, res.params);
133
133
  return this.wrapVirtualExpressionInSubquery(meta, expr, where, options, type);
134
134
  }
135
- /* v8 ignore next 2 */
135
+ /* v8 ignore next */
136
136
  return res;
137
137
  }
138
138
  async *streamFromVirtual(entityName, where, options) {
139
139
  const meta = this.metadata.get(entityName);
140
- /* v8 ignore next 3 */
140
+ /* v8 ignore next */
141
141
  if (!meta.expression) {
142
142
  return;
143
143
  }
@@ -161,7 +161,7 @@ export class AbstractSqlDriver extends DatabaseDriver {
161
161
  yield* this.wrapVirtualExpressionInSubqueryStream(meta, expr, where, options, QueryType.SELECT);
162
162
  return;
163
163
  }
164
- /* v8 ignore next 2 */
164
+ /* v8 ignore next */
165
165
  yield* res;
166
166
  }
167
167
  async wrapVirtualExpressionInSubquery(meta, expression, where, options, type) {
@@ -201,7 +201,7 @@ export class AbstractSqlDriver extends DatabaseDriver {
201
201
  }
202
202
  mapResult(result, meta, populate = [], qb, map = {}) {
203
203
  const ret = super.mapResult(result, meta);
204
- /* v8 ignore next 3 */
204
+ /* v8 ignore next */
205
205
  if (!ret) {
206
206
  return null;
207
207
  }
@@ -216,7 +216,7 @@ export class AbstractSqlDriver extends DatabaseDriver {
216
216
  joinedProps.forEach(hint => {
217
217
  const [propName, ref] = hint.field.split(':', 2);
218
218
  const prop = meta.properties[propName];
219
- /* v8 ignore next 3 */
219
+ /* v8 ignore next */
220
220
  if (!prop) {
221
221
  return;
222
222
  }
@@ -230,7 +230,7 @@ export class AbstractSqlDriver extends DatabaseDriver {
230
230
  path += '[pivot]';
231
231
  }
232
232
  const relationAlias = qb.getAliasForJoinPath(path, { matchPopulateJoins: true });
233
- /* v8 ignore next 3 */
233
+ /* v8 ignore next */
234
234
  if (!relationAlias) {
235
235
  return;
236
236
  }
@@ -279,7 +279,7 @@ export class AbstractSqlDriver extends DatabaseDriver {
279
279
  meta2.props
280
280
  .filter(prop => !ref && prop.persist === false && prop.fieldNames)
281
281
  .forEach(prop => {
282
- /* v8 ignore next 3 */
282
+ /* v8 ignore next */
283
283
  if (prop.fieldNames.length > 1) { // composite keys
284
284
  relationPojo[prop.name] = prop.fieldNames.map(name => root[`${relationAlias}__${name}`]);
285
285
  }
@@ -514,7 +514,7 @@ export class AbstractSqlDriver extends DatabaseDriver {
514
514
  }
515
515
  const res = await this.execute(sql, params, 'run', options.ctx, options.loggerContext);
516
516
  let pk;
517
- /* v8 ignore next 3 */
517
+ /* v8 ignore next */
518
518
  if (pks.length > 1) { // owner has composite pk
519
519
  pk = data.map(d => Utils.getPrimaryKeyCond(d, pks));
520
520
  }
@@ -768,7 +768,7 @@ export class AbstractSqlDriver extends DatabaseDriver {
768
768
  await this.rethrow(query.execute());
769
769
  continue;
770
770
  }
771
- /* v8 ignore next 5 */
771
+ /* v8 ignore next */
772
772
  const query = qb.update({ [coll.property.mappedBy]: pks })
773
773
  .where({ [cols.join(Utils.PK_SEPARATOR)]: { $in: insertDiff } });
774
774
  await this.rethrow(query.execute());
@@ -21,12 +21,12 @@ export class AbstractSqlPlatform extends Platform {
21
21
  lookupExtensions(orm) {
22
22
  SqlSchemaGenerator.register(orm);
23
23
  }
24
- /* v8 ignore next 3: kept for type inference only */
24
+ /* v8 ignore next: kept for type inference only */
25
25
  getSchemaGenerator(driver, em) {
26
26
  return new SqlSchemaGenerator(em ?? driver);
27
27
  }
28
- /* v8 ignore next 4 */
29
28
  /** @internal */
29
+ /* v8 ignore next */
30
30
  createNativeQueryBuilder() {
31
31
  return new NativeQueryBuilder(this);
32
32
  }
@@ -168,7 +168,7 @@ export class MsSqlNativeQueryBuilder extends NativeQueryBuilder {
168
168
  this.parts.push(`order by ${this.options.orderBy}`);
169
169
  }
170
170
  if (this.options.offset != null) {
171
- /* v8 ignore next 3 */
171
+ /* v8 ignore next */
172
172
  if (!this.options.orderBy) {
173
173
  throw new Error('Order by clause is required for pagination');
174
174
  }
@@ -6,7 +6,7 @@ export class MySqlExceptionConverter extends ExceptionConverter {
6
6
  * @see https://github.com/doctrine/dbal/blob/master/src/Driver/AbstractMySQLDriver.php
7
7
  */
8
8
  convertException(exception) {
9
- /* v8 ignore start */
9
+ /* v8 ignore next */
10
10
  switch (exception.errno) {
11
11
  case 1213:
12
12
  return new DeadlockException(exception);
@@ -75,7 +75,6 @@ export class MySqlExceptionConverter extends ExceptionConverter {
75
75
  case 1566:
76
76
  return new NotNullConstraintViolationException(exception);
77
77
  }
78
- /* v8 ignore stop */
79
78
  return super.convertException(exception);
80
79
  }
81
80
  }
@@ -78,7 +78,7 @@ export class MySqlSchemaHelper extends SchemaHelper {
78
78
  return ret;
79
79
  }
80
80
  getCreateIndexSQL(tableName, index, partialExpression = false) {
81
- /* v8 ignore next 3 */
81
+ /* v8 ignore next */
82
82
  if (index.expression && !partialExpression) {
83
83
  return index.expression;
84
84
  }
@@ -146,7 +146,7 @@ export class MySqlSchemaHelper extends SchemaHelper {
146
146
  return ret;
147
147
  }
148
148
  async getAllChecks(connection, tables) {
149
- /* v8 ignore next 3 */
149
+ /* v8 ignore next */
150
150
  if (!(await this.supportsCheckConstraints(connection))) {
151
151
  return {};
152
152
  }
@@ -1,4 +1,5 @@
1
1
  import { ConnectionException, ExceptionConverter, InvalidFieldNameException, LockWaitTimeoutException, NonUniqueFieldNameException, CheckConstraintViolationException, NotNullConstraintViolationException, ReadOnlyException, SyntaxErrorException, TableExistsException, TableNotFoundException, UniqueConstraintViolationException, ForeignKeyConstraintViolationException, } from '@mikro-orm/core';
2
+ /* v8 ignore next */
2
3
  export class SqliteExceptionConverter extends ExceptionConverter {
3
4
  /**
4
5
  * @inheritDoc
@@ -6,7 +7,6 @@ export class SqliteExceptionConverter extends ExceptionConverter {
6
7
  * @see https://github.com/doctrine/dbal/blob/master/src/Driver/AbstractSQLiteDriver.php
7
8
  */
8
9
  convertException(exception) {
9
- /* v8 ignore start */
10
10
  if (exception.message.includes('database is locked')) {
11
11
  return new LockWaitTimeoutException(exception);
12
12
  }
@@ -46,7 +46,6 @@ export class SqliteExceptionConverter extends ExceptionConverter {
46
46
  if (exception.message.includes('FOREIGN KEY constraint failed')) {
47
47
  return new ForeignKeyConstraintViolationException(exception);
48
48
  }
49
- /* v8 ignore stop */
50
49
  return super.convertException(exception);
51
50
  }
52
51
  }
@@ -114,7 +114,7 @@ export class SqliteSchemaHelper extends SchemaHelper {
114
114
  }).join(';\n');
115
115
  }
116
116
  getCreateIndexSQL(tableName, index) {
117
- /* v8 ignore next 3 */
117
+ /* v8 ignore next */
118
118
  if (index.expression) {
119
119
  return index.expression;
120
120
  }
@@ -134,7 +134,7 @@ export class SqliteSchemaHelper extends SchemaHelper {
134
134
  const constraints = [];
135
135
  // extract all columns definitions
136
136
  let columnsDef = sql.replaceAll('\n', '').match(new RegExp(`create table [\`"']?.*?[\`"']? \\((.*)\\)`, 'i'))?.[1];
137
- /* v8 ignore start */
137
+ /* v8 ignore next */
138
138
  if (columnsDef) {
139
139
  if (columnsDef.includes(', constraint ')) {
140
140
  constraints.push(...columnsDef.substring(columnsDef.indexOf(', constraint') + 2).split(', '));
@@ -150,7 +150,6 @@ export class SqliteSchemaHelper extends SchemaHelper {
150
150
  }
151
151
  }
152
152
  }
153
- /* v8 ignore stop */
154
153
  return { columns, constraints };
155
154
  }
156
155
  async getColumns(connection, tableName, schemaName) {
@@ -194,7 +193,7 @@ export class SqliteSchemaHelper extends SchemaHelper {
194
193
  // check constraints are defined as (note that last closing paren is missing):
195
194
  // `type` text check (`type` in ('local', 'global')
196
195
  const match = item.match(/[`["']([^`\]"']+)[`\]"'] text check \(.* \((.*)\)/i);
197
- /* v8 ignore next 3 */
196
+ /* v8 ignore next */
198
197
  if (match) {
199
198
  o[match[1]] = match[2].split(',').map((item) => item.trim().match(/^\(?'(.*)'/)[1]);
200
199
  }
@@ -321,7 +320,7 @@ export class SqliteSchemaHelper extends SchemaHelper {
321
320
  for (const index of Object.values(diff.changedIndexes)) {
322
321
  this.append(ret, this.dropIndex(diff.name, index));
323
322
  }
324
- /* v8 ignore next 3 */
323
+ /* v8 ignore next */
325
324
  if (!safe && Object.values(diff.removedColumns).length > 0) {
326
325
  this.append(ret, this.getDropColumnsSQL(tableName, Object.values(diff.removedColumns), schemaName));
327
326
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/knex",
3
- "version": "7.0.0-dev.75",
3
+ "version": "7.0.0-dev.77",
4
4
  "description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -57,6 +57,6 @@
57
57
  "@mikro-orm/core": "^6.6.1"
58
58
  },
59
59
  "peerDependencies": {
60
- "@mikro-orm/core": "7.0.0-dev.75"
60
+ "@mikro-orm/core": "7.0.0-dev.77"
61
61
  }
62
62
  }
@@ -180,7 +180,7 @@ export class ObjectCriteriaNode extends CriteriaNode {
180
180
  o[key] = value;
181
181
  return;
182
182
  }
183
- /* v8 ignore next 4 */
183
+ /* v8 ignore next */
184
184
  if (key === '$and') {
185
185
  o.$and.push({ [key]: value });
186
186
  return;
@@ -253,7 +253,7 @@ export class QueryBuilder {
253
253
  * Apply filters to the QB where condition.
254
254
  */
255
255
  async applyFilters(filterOptions = {}) {
256
- /* v8 ignore next 3 */
256
+ /* v8 ignore next */
257
257
  if (!this.em) {
258
258
  throw new Error('Cannot apply filters, this QueryBuilder is not attached to an EntityManager');
259
259
  }
@@ -903,7 +903,7 @@ export class QueryBuilder {
903
903
  qb[prop] = properties.includes(prop) ? Utils.copy(this[prop]) : this[prop];
904
904
  }
905
905
  delete RawQueryFragment.cloneRegistry;
906
- /* v8 ignore next 3 */
906
+ /* v8 ignore next */
907
907
  if (this._fields && !reset.includes('_fields')) {
908
908
  qb._fields = [...this._fields];
909
909
  }
@@ -1046,7 +1046,7 @@ export class QueryBuilder {
1046
1046
  }
1047
1047
  const [a, f] = this.helper.splitField(field);
1048
1048
  const prop = this.helper.getProperty(f, a);
1049
- /* v8 ignore next 3 */
1049
+ /* v8 ignore next */
1050
1050
  if (prop && [ReferenceKind.ONE_TO_MANY, ReferenceKind.MANY_TO_MANY].includes(prop.kind)) {
1051
1051
  return;
1052
1052
  }
@@ -1408,7 +1408,7 @@ export class QueryBuilder {
1408
1408
  }
1409
1409
  return false;
1410
1410
  });
1411
- /* v8 ignore next 3 */
1411
+ /* v8 ignore next */
1412
1412
  if (field instanceof RawQueryFragment) {
1413
1413
  innerQuery.select(field);
1414
1414
  }
@@ -1517,7 +1517,7 @@ export class QueryBuilder {
1517
1517
  return new QueryBuilderHelper(this.mainAlias.entityName, this.mainAlias.aliasName, this._aliases, this.subQueries, this.driver);
1518
1518
  }
1519
1519
  ensureFromClause() {
1520
- /* v8 ignore next 3 */
1520
+ /* v8 ignore next */
1521
1521
  if (!this._mainAlias) {
1522
1522
  throw new Error(`Cannot proceed to build a query because the main alias is not set.`);
1523
1523
  }
@@ -1527,8 +1527,8 @@ export class QueryBuilder {
1527
1527
  throw new Error('This QueryBuilder instance is already finalized, clone it first if you want to modify it.');
1528
1528
  }
1529
1529
  }
1530
- /* v8 ignore start */
1531
1530
  /** @ignore */
1531
+ /* v8 ignore next */
1532
1532
  [inspect.custom](depth = 2) {
1533
1533
  const object = { ...this };
1534
1534
  const hidden = ['metadata', 'driver', 'context', 'platform', 'type'];
@@ -26,7 +26,7 @@ export class QueryBuilderHelper {
26
26
  if (isRaw(field)) {
27
27
  return raw(field.sql, field.params);
28
28
  }
29
- /* v8 ignore next 3 */
29
+ /* v8 ignore next */
30
30
  if (typeof field !== 'string') {
31
31
  return field;
32
32
  }
@@ -420,7 +420,7 @@ export class QueryBuilderHelper {
420
420
  }
421
421
  // operators
422
422
  const op = Object.keys(QueryOperator).find(op => op in value);
423
- /* v8 ignore next 3 */
423
+ /* v8 ignore next */
424
424
  if (!op) {
425
425
  throw new Error(`Invalid query condition: ${inspect(cond, { depth: 5 })}`);
426
426
  }
@@ -456,7 +456,7 @@ export class QueryBuilderHelper {
456
456
  const [a, f] = this.splitField(key);
457
457
  const prop = this.getProperty(f, a);
458
458
  if (op === '$fulltext') {
459
- /* v8 ignore next 3 */
459
+ /* v8 ignore next */
460
460
  if (!prop) {
461
461
  throw new Error(`Cannot use $fulltext operator on ${key}, property not found`);
462
462
  }
@@ -63,7 +63,7 @@ export class DatabaseTable {
63
63
  const mappedType = this.platform.getMappedType(type);
64
64
  if (mappedType instanceof DecimalType) {
65
65
  const match = prop.columnTypes[idx].match(/\w+\((\d+), ?(\d+)\)/);
66
- /* v8 ignore next 5 */
66
+ /* v8 ignore next */
67
67
  if (match) {
68
68
  prop.precision ??= +match[1];
69
69
  prop.scale ??= +match[2];
@@ -308,7 +308,7 @@ export class SchemaComparator {
308
308
  const [removedColumn, addedColumn] = candidateColumns[0];
309
309
  const removedColumnName = removedColumn.name;
310
310
  const addedColumnName = addedColumn.name;
311
- /* v8 ignore next 3 */
311
+ /* v8 ignore next */
312
312
  if (tableDifferences.renamedColumns[removedColumnName]) {
313
313
  continue;
314
314
  }
@@ -518,7 +518,7 @@ export class SchemaComparator {
518
518
  return simplify(expr1) !== simplify(expr2);
519
519
  }
520
520
  parseJsonDefault(defaultValue) {
521
- /* v8 ignore next 3 */
521
+ /* v8 ignore next */
522
522
  if (!defaultValue) {
523
523
  return null;
524
524
  }
@@ -74,7 +74,7 @@ export class SchemaHelper {
74
74
  return `alter table ${tableReference} rename column ${oldColumnName} to ${columnName}`;
75
75
  }
76
76
  getCreateIndexSQL(tableName, index) {
77
- /* v8 ignore next 3 */
77
+ /* v8 ignore next */
78
78
  if (index.expression) {
79
79
  return index.expression;
80
80
  }
@@ -141,7 +141,7 @@ export class SchemaHelper {
141
141
  for (const check of Object.values(diff.changedChecks)) {
142
142
  ret.push(this.dropConstraint(diff.name, check.name));
143
143
  }
144
- /* v8 ignore next 3 */
144
+ /* v8 ignore next */
145
145
  if (!safe && Object.values(diff.removedColumns).length > 0) {
146
146
  ret.push(this.getDropColumnsSQL(tableName, Object.values(diff.removedColumns), schemaName));
147
147
  }
@@ -224,7 +224,7 @@ export class SchemaHelper {
224
224
  const defaultName = this.platform.getDefaultPrimaryName(table.name, pkIndex.columnNames);
225
225
  return pkIndex?.keyName !== defaultName;
226
226
  }
227
- /* v8 ignore next 3 */
227
+ /* v8 ignore next */
228
228
  castColumn(name, type) {
229
229
  return '';
230
230
  }
@@ -341,11 +341,11 @@ export class SchemaHelper {
341
341
  getDropDatabaseSQL(name) {
342
342
  return `drop database if exists ${this.quote(name)}`;
343
343
  }
344
- /* v8 ignore next 3 */
344
+ /* v8 ignore next */
345
345
  getCreateNamespaceSQL(name) {
346
346
  return `create schema if not exists ${this.quote(name)}`;
347
347
  }
348
- /* v8 ignore next 3 */
348
+ /* v8 ignore next */
349
349
  getDropNamespaceSQL(name) {
350
350
  return `drop schema if exists ${this.quote(name)}`;
351
351
  }
@@ -467,7 +467,7 @@ export class SchemaHelper {
467
467
  getReferencedTableName(referencedTableName, schema) {
468
468
  const [schemaName, tableName] = this.splitTableName(referencedTableName);
469
469
  schema = schemaName ?? schema ?? this.platform.getConfig().get('schema');
470
- /* v8 ignore next 3 */
470
+ /* v8 ignore next */
471
471
  if (schema && schemaName === '*') {
472
472
  return `${schema}.${referencedTableName.replace(/^\*\./, '')}`;
473
473
  }
@@ -36,7 +36,7 @@ export class SqlSchemaGenerator extends AbstractSchemaGenerator {
36
36
  }
37
37
  return true;
38
38
  }
39
- /* v8 ignore next 3 */
39
+ /* v8 ignore next */
40
40
  if (options?.clear) {
41
41
  await this.clear({ ...options, clearIdentityMap: false });
42
42
  }
@@ -69,7 +69,7 @@ export class SqlSchemaGenerator extends AbstractSchemaGenerator {
69
69
  if (this.platform.supportsNativeEnums()) {
70
70
  const created = [];
71
71
  for (const [enumName, enumOptions] of Object.entries(toSchema.getNativeEnums())) {
72
- /* v8 ignore next 3 */
72
+ /* v8 ignore next */
73
73
  if (created.includes(enumName)) {
74
74
  continue;
75
75
  }
@@ -107,7 +107,7 @@ export class SqlSchemaGenerator extends AbstractSchemaGenerator {
107
107
  }
108
108
  async clear(options) {
109
109
  // truncate by default, so no value is considered as true
110
- /* v8 ignore next 3 */
110
+ /* v8 ignore next */
111
111
  if (options?.truncate === false) {
112
112
  return super.clear(options);
113
113
  }