Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

@mikro-orm/sql

Package Overview
Dependencies
Maintainers
1
Versions
190
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mikro-orm/sql - npm Package Compare versions

Comparing version
7.0.0-dev.129
to
7.0.0-dev.130
+2
-2
package.json
{
"name": "@mikro-orm/sql",
"version": "7.0.0-dev.129",
"version": "7.0.0-dev.130",
"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.",

@@ -59,4 +59,4 @@ "type": "module",

"peerDependencies": {
"@mikro-orm/core": "7.0.0-dev.129"
"@mikro-orm/core": "7.0.0-dev.130"
}
}
import { ALIAS_REPLACEMENT, GroupOperator, QueryFlag, raw, RawQueryFragment, ReferenceKind, Utils, } from '@mikro-orm/core';
import { CriteriaNode } from './CriteriaNode.js';
import { JoinType, QueryType } from './enums.js';
const COLLECTION_OPERATORS = ['$some', '$none', '$every', '$size'];
/**

@@ -18,3 +19,3 @@ * @internal

if (this.shouldAutoJoin(qb, nestedAlias)) {
if (keys.some(k => ['$some', '$none', '$every'].includes(k))) {
if (keys.some(k => COLLECTION_OPERATORS.includes(k))) {
if (![ReferenceKind.MANY_TO_MANY, ReferenceKind.ONE_TO_MANY].includes(this.prop.kind)) {

@@ -35,3 +36,3 @@ // ignore collection operators when used on a non-relational property - this can happen when they get into

for (const key of keys) {
if (typeof key !== 'string' || !['$some', '$none', '$every'].includes(key)) {
if (typeof key !== 'string' || !COLLECTION_OPERATORS.includes(key)) {
throw new Error('Mixing collection operators with other filters is not allowed.');

@@ -41,7 +42,16 @@ }

const qb2 = qb.clone(true, ['_schema']);
const joinAlias = qb2.getNextAlias(this.prop.targetMeta.class);
const sub = qb2
.from(parentMeta.class)
.innerJoin(this.key, qb2.getNextAlias(this.prop.targetMeta.class))
// eslint-disable-next-line no-unexpected-multiline
[key === '$size' ? 'leftJoin' : 'innerJoin'](this.key, joinAlias)
.select(parentMeta.primaryKeys);
if (key === '$every') {
if (key === '$size') {
const sizeCondition = typeof payload === 'number' ? { $eq: payload } : payload;
const pks = this.prop.referencedColumnNames;
const countExpr = raw(`count(${pks.map(() => '??').join(', ')})`, pks.map(pk => `${joinAlias}.${pk}`));
sub.groupBy(parentMeta.primaryKeys);
sub.having({ $and: Object.keys(sizeCondition).map(op => ({ [countExpr]: { [op]: sizeCondition[op] } })) });
}
else if (key === '$every') {
sub.where({ $not: { [this.key]: payload } });

@@ -52,3 +62,3 @@ }

}
const op = key === '$some' ? '$in' : '$nin';
const op = ['$size', '$some'].includes(key) ? '$in' : '$nin';
$and.push({

@@ -131,3 +141,3 @@ [Utils.getPrimaryKeyHash(primaryKeys)]: { [op]: sub.getNativeQuery().toRaw() },

if (this.shouldAutoJoin(qb, nestedAlias)) {
return !keys.some(k => ['$some', '$none', '$every'].includes(k));
return !keys.some(k => COLLECTION_OPERATORS.includes(k));
}

@@ -206,3 +216,3 @@ return keys.some(field => {

}
if (keys.some(k => ['$some', '$none', '$every'].includes(k))) {
if (keys.some(k => COLLECTION_OPERATORS.includes(k))) {
return true;

@@ -209,0 +219,0 @@ }

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

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