@mikro-orm/knex 6.0.2-dev.8 → 6.0.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/knex",
3
- "version": "6.0.2-dev.8",
3
+ "version": "6.0.2",
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
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -63,9 +63,9 @@
63
63
  "sqlstring": "2.3.3"
64
64
  },
65
65
  "devDependencies": {
66
- "@mikro-orm/core": "^6.0.1"
66
+ "@mikro-orm/core": "^6.0.2"
67
67
  },
68
68
  "peerDependencies": {
69
- "@mikro-orm/core": "6.0.2-dev.8"
69
+ "@mikro-orm/core": "^6.0.0"
70
70
  }
71
71
  }
@@ -27,8 +27,11 @@ class ObjectCriteriaNode extends CriteriaNode_1.CriteriaNode {
27
27
  throw new Error('Mixing collection operators with other filters is not allowed.');
28
28
  }
29
29
  const payload = this.payload[key].unwrap();
30
- const sub = qb.clone(true).innerJoin(this.key, qb.getNextAlias(this.prop.type));
31
- sub.select(this.prop.targetMeta.primaryKeys);
30
+ const sub = qb
31
+ .clone(true)
32
+ .from(this.parent.entityName)
33
+ .innerJoin(this.key, qb.getNextAlias(this.prop.type))
34
+ .select(this.prop.targetMeta.primaryKeys);
32
35
  if (key === '$every') {
33
36
  sub.where({ $not: { [this.key]: payload } });
34
37
  }
@@ -153,7 +153,7 @@ class DatabaseTable {
153
153
  }
154
154
  getEntityDeclaration(namingStrategy, schemaHelper, scalarPropertiesForRelations) {
155
155
  const { fksOnColumnProps, fksOnStandaloneProps, columnFks, fkIndexes, nullableForeignKeys, skippedColumnNames, } = this.foreignKeysToProps(namingStrategy, scalarPropertiesForRelations);
156
- let name = namingStrategy.getClassName(this.name, '_');
156
+ let name = namingStrategy.getEntityName(this.name, this.schema);
157
157
  name = name.match(/^\d/) ? 'E' + name : name;
158
158
  const schema = new core_1.EntitySchema({ name, collection: this.name, schema: this.schema });
159
159
  const compositeFkIndexes = {};
@@ -561,7 +561,7 @@ class DatabaseTable {
561
561
  }
562
562
  getPropertyTypeForForeignKey(namingStrategy, fk) {
563
563
  const parts = fk.referencedTableName.split('.', 2);
564
- return namingStrategy.getClassName(parts.length > 1 ? parts[1] : parts[0], '_');
564
+ return namingStrategy.getEntityName(...parts.reverse());
565
565
  }
566
566
  getPropertyTypeForColumn(namingStrategy, column, fk) {
567
567
  if (fk) {
package/typings.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Knex } from 'knex';
2
- import type { CheckCallback, Dictionary, EntityProperty, GroupOperator, RawQueryFragment, QBFilterQuery, QueryOrderMap, Type, QueryFlag } from '@mikro-orm/core';
2
+ import type { CheckCallback, Dictionary, EntityProperty, GroupOperator, RawQueryFragment, QBFilterQuery, QueryOrderMap, Type, QueryFlag, AnyEntity, EntityName } from '@mikro-orm/core';
3
3
  import type { JoinType, QueryType } from './query/enums';
4
4
  import type { DatabaseSchema, DatabaseTable } from './schema';
5
5
  export interface Table {
@@ -120,6 +120,7 @@ export interface IQueryBuilder<T> {
120
120
  _fields?: Field<T>[];
121
121
  select(fields: Field<T> | Field<T>[], distinct?: boolean): this;
122
122
  addSelect(fields: string | string[]): this;
123
+ from<T extends AnyEntity<T> = AnyEntity>(target: EntityName<T> | IQueryBuilder<T>, aliasName?: string): IQueryBuilder<T>;
123
124
  insert(data: any): this;
124
125
  update(data: any): this;
125
126
  delete(cond?: QBFilterQuery): this;