New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@mikro-orm/knex

Package Overview
Dependencies
Maintainers
1
Versions
3351
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mikro-orm/knex - npm Package Compare versions

Comparing version

to
7.0.0-dev.7

10

AbstractSqlDriver.d.ts

@@ -17,8 +17,8 @@ import { type AnyEntity, type Collection, type Configuration, type ConnectionType, type Constructor, type CountOptions, DatabaseDriver, type DeleteOptions, type Dictionary, type DriverMethodOptions, type EntityData, type EntityDictionary, type EntityField, EntityManagerType, type EntityMetadata, type EntityName, type EntityProperty, type FilterQuery, type FindOneOptions, type FindOptions, type LockOptions, type LoggingOptions, type NativeInsertUpdateManyOptions, type NativeInsertUpdateOptions, type ObjectQuery, type Options, type OrderDefinition, type PopulateOptions, type PopulatePath, type Primary, type QueryOrderMap, type QueryResult, RawQueryFragment, type Transaction, type UpsertManyOptions, type UpsertOptions } from '@mikro-orm/core';

createEntityManager(useContext?: boolean): this[typeof EntityManagerType];
find<T extends object, P extends string = never, F extends string = PopulatePath.ALL, E extends string = never>(entityName: string, where: FilterQuery<T>, options?: FindOptions<T, P, F, E>): Promise<EntityData<T>[]>;
findOne<T extends object, P extends string = never, F extends string = PopulatePath.ALL, E extends string = never>(entityName: string, where: FilterQuery<T>, options?: FindOneOptions<T, P, F, E>): Promise<EntityData<T> | null>;
find<T extends object, P extends string = never, F extends string = PopulatePath.ALL, E extends string = never>(entityName: string, where: ObjectQuery<T>, options?: FindOptions<T, P, F, E>): Promise<EntityData<T>[]>;
findOne<T extends object, P extends string = never, F extends string = PopulatePath.ALL, E extends string = never>(entityName: string, where: ObjectQuery<T>, options?: FindOneOptions<T, P, F, E>): Promise<EntityData<T> | null>;
protected hasToManyJoins<T extends object>(hint: PopulateOptions<T>, meta: EntityMetadata<T>): boolean;
findVirtual<T extends object>(entityName: string, where: FilterQuery<T>, options: FindOptions<T, any, any, any>): Promise<EntityData<T>[]>;
countVirtual<T extends object>(entityName: string, where: FilterQuery<T>, options: CountOptions<T, any>): Promise<number>;
protected findFromVirtual<T extends object>(entityName: string, where: FilterQuery<T>, options: FindOptions<T, any> | CountOptions<T, any>, type: QueryType): Promise<EntityData<T>[] | number>;
findVirtual<T extends object>(entityName: string, where: ObjectQuery<T>, options: FindOptions<T, any, any, any>): Promise<EntityData<T>[]>;
countVirtual<T extends object>(entityName: string, where: ObjectQuery<T>, options: CountOptions<T, any>): Promise<number>;
protected findFromVirtual<T extends object>(entityName: string, where: ObjectQuery<T>, options: FindOptions<T, any> | CountOptions<T, any>, type: QueryType): Promise<EntityData<T>[] | number>;
protected wrapVirtualExpressionInSubquery<T extends object>(meta: EntityMetadata<T>, expression: string, where: FilterQuery<T>, options: FindOptions<T, any>, type: QueryType): Promise<T[] | number>;

@@ -25,0 +25,0 @@ mapResult<T extends object>(result: EntityData<T>, meta: EntityMetadata<T>, populate?: PopulateOptions<T>[], qb?: QueryBuilder<T, any, any, any>, map?: Dictionary): EntityData<T> | null;

{
"name": "@mikro-orm/knex",
"version": "7.0.0-dev.6",
"version": "7.0.0-dev.7",
"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.",

@@ -57,7 +57,7 @@ "type": "module",

"devDependencies": {
"@mikro-orm/core": "^6.4.7"
"@mikro-orm/core": "^6.4.9"
},
"peerDependencies": {
"@mikro-orm/core": "7.0.0-dev.6"
"@mikro-orm/core": "7.0.0-dev.7"
}
}

@@ -72,3 +72,3 @@ import { inspect } from 'node:util';

joinAlias = qb.getAliasForJoinPath(this.parent.getPath());
return Utils.getPrimaryKeyHash(this.prop.ownColumns.map(col => `${joinAlias ?? qb.alias}.${col}`));
return Utils.getPrimaryKeyHash(this.prop.joinColumns.map(col => `${joinAlias ?? qb.alias}.${col}`));
}

@@ -75,0 +75,0 @@ const alias = joinAlias ?? qb.alias;

@@ -203,8 +203,9 @@ import { ALIAS_REPLACEMENT, QueryFlag, raw, RawQueryFragment, ReferenceKind, Utils, } from '@mikro-orm/core';

const method = qb.hasFlag(QueryFlag.INFER_POPULATE) ? 'joinAndSelect' : 'join';
const path = this.getPath();
if (this.prop.kind === ReferenceKind.MANY_TO_MANY && (scalar || operator)) {
qb.join(field, nestedAlias, undefined, JoinType.pivotJoin, this.getPath());
qb.join(field, nestedAlias, undefined, JoinType.pivotJoin, path);
}
else {
const prev = qb._fields?.slice();
qb[method](field, nestedAlias, undefined, JoinType.leftJoin, this.getPath());
qb[method](field, nestedAlias, undefined, JoinType.leftJoin, path);
if (!qb.hasFlag(QueryFlag.INFER_POPULATE)) {

@@ -214,2 +215,3 @@ qb._fields = prev;

}
qb.scheduleFilterCheck(path);
return nestedAlias;

@@ -216,0 +218,0 @@ }

import { inspect } from 'node:util';
import { type AnyEntity, type ConnectionType, type Dictionary, type EntityData, type EntityKey, type EntityMetadata, type EntityName, type EntityProperty, type ExpandProperty, type FlushMode, type GroupOperator, type Loaded, LockMode, type LoggingOptions, type MetadataStorage, type ObjectQuery, PopulateHint, type PopulateOptions, type QBFilterQuery, type QBQueryOrderMap, QueryFlag, type QueryOrderMap, type QueryResult, RawQueryFragment, type RequiredEntityData, type Transaction } from '@mikro-orm/core';
import { type AnyEntity, type ConnectionType, type Dictionary, type EntityData, type EntityKey, type EntityManager, type EntityMetadata, type EntityName, type EntityProperty, type ExpandProperty, type FlushMode, type GroupOperator, type Loaded, LockMode, type LoggingOptions, type MetadataStorage, type ObjectQuery, PopulateHint, type PopulateOptions, type QBFilterQuery, type QBQueryOrderMap, QueryFlag, type QueryOrderMap, type QueryResult, RawQueryFragment, type RequiredEntityData, type Transaction } from '@mikro-orm/core';
import { JoinType, QueryType } from './enums.js';

@@ -144,2 +144,11 @@ import type { AbstractSqlDriver } from '../AbstractSqlDriver.js';

applyFilters(filterOptions?: Dictionary<boolean | Dictionary> | string[] | boolean): Promise<void>;
private readonly autoJoinedPaths;
/**
* @internal
*/
scheduleFilterCheck(path: string): void;
/**
* @internal
*/
applyJoinedFilters(em: EntityManager, filterOptions?: Dictionary<boolean | Dictionary> | string[] | boolean): Promise<void>;
withSubQuery(subQuery: RawQueryFragment | NativeQueryBuilder, alias: string): this;

@@ -146,0 +155,0 @@ where(cond: QBFilterQuery<Entity>, operator?: keyof typeof GroupOperator): this;

@@ -260,2 +260,30 @@ import { inspect } from 'node:util';

}
autoJoinedPaths = [];
/**
* @internal
*/
scheduleFilterCheck(path) {
this.autoJoinedPaths.push(path);
}
/**
* @internal
*/
async applyJoinedFilters(em, filterOptions = {}) {
for (const path of this.autoJoinedPaths) {
const join = this.getJoinForPath(path);
if (join.type === JoinType.pivotJoin) {
continue;
}
const cond = await em.applyFilters(join.prop.type, join.cond, filterOptions, 'read');
if (Utils.hasObjectKeys(cond)) {
if (Utils.hasObjectKeys(join.cond)) {
/* istanbul ignore next */
join.cond = { $and: [join.cond, cond] };
}
else {
join.cond = { ...cond };
}
}
}
}
withSubQuery(subQuery, alias) {

@@ -1156,3 +1184,3 @@ this.ensureNotFinalized();

join.cond_ ??= join.cond;
join.cond = filter ? { ...join.cond } : {};
join.cond = { ...join.cond };
}

@@ -1159,0 +1187,0 @@ if (typeof this[key] === 'object') {

@@ -702,3 +702,4 @@ import { Cascade, DecimalType, EntitySchema, ReferenceKind, t, Type, UnknownType, Utils, } from '@mikro-orm/core';

const properties = Utils.unique(Utils.flatten(Utils.asArray(index.properties).map(prop => {
const root = prop.replace(/\..+$/, '');
const parts = prop.split('.');
const root = parts[0];
if (meta.properties[prop]) {

@@ -710,5 +711,16 @@ if (meta.properties[prop].embeddedPath) {

}
const rootProp = meta.properties[root];
// inline embedded property index, we need to find the field name of the child property
if (rootProp?.embeddable && !rootProp.object && parts.length > 1) {
const expand = (p, i) => {
if (parts.length === i) {
return p.fieldNames[0];
}
return expand(p.embeddedProps[parts[i]], i + 1);
};
return [expand(rootProp, 1)];
}
// json index, we need to rename the column only
if (meta.properties[root]) {
return [prop.replace(root, meta.properties[root].fieldNames[0])];
if (rootProp) {
return [prop.replace(root, rootProp.fieldNames[0])];
}

@@ -715,0 +727,0 @@ /* v8 ignore next */

@@ -166,2 +166,3 @@ import type { DeferMode, CheckCallback, Dictionary, EntityProperty, GroupOperator, RawQueryFragment, QBFilterQuery, QueryOrderMap, Type, QueryFlag, AnyEntity, EntityName } from '@mikro-orm/core';

hasFlag(flag: QueryFlag): boolean;
scheduleFilterCheck(path: string): void;
}

@@ -168,0 +169,0 @@ export interface ICriteriaNodeProcessOptions {

Sorry, the diff of this file is too big to display