@mikro-orm/sql
Advanced tools
@@ -65,3 +65,3 @@ 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 StreamOptions, type Transaction, type UpsertManyOptions, type UpsertOptions } from '@mikro-orm/core'; | ||
| */ | ||
| mapPropToFieldNames<T extends object>(qb: QueryBuilder<T, any, any, any>, prop: EntityProperty<T>, tableAlias: string, explicitFields?: readonly Field<T>[]): Field<T>[]; | ||
| mapPropToFieldNames<T extends object>(qb: QueryBuilder<T, any, any, any>, prop: EntityProperty<T>, tableAlias: string, meta: EntityMetadata<T>, schema?: string, explicitFields?: readonly Field<T>[]): Field<T>[]; | ||
| /** @internal */ | ||
@@ -82,3 +82,3 @@ createQueryBuilder<T extends object>(entityName: EntityName<T> | QueryBuilder<T, any, any, any>, ctx?: Transaction, preferredConnectionType?: ConnectionType, convertCustomTypes?: boolean, loggerContext?: LoggingOptions, alias?: string, em?: SqlEntityManager): QueryBuilder<T, any, any, any>; | ||
| protected processField<T extends object>(meta: EntityMetadata<T>, prop: EntityProperty<T> | undefined, field: string, ret: Field<T>[]): void; | ||
| protected buildFields<T extends object>(meta: EntityMetadata<T>, populate: PopulateOptions<T>[], joinedProps: PopulateOptions<T>[], qb: QueryBuilder<T, any, any, any>, alias: string, options: Pick<FindOptions<T, any, any, any>, 'strategy' | 'fields' | 'exclude'>): Field<T>[]; | ||
| protected buildFields<T extends object>(meta: EntityMetadata<T>, populate: PopulateOptions<T>[], joinedProps: PopulateOptions<T>[], qb: QueryBuilder<T, any, any, any>, alias: string, options: Pick<FindOptions<T, any, any, any>, 'strategy' | 'fields' | 'exclude'>, schema?: string): Field<T>[]; | ||
| } | ||
@@ -85,0 +85,0 @@ interface FieldsForJoinedLoadOptions<T extends object> { |
+2
-2
| { | ||
| "name": "@mikro-orm/sql", | ||
| "version": "7.0.0-dev.153", | ||
| "version": "7.0.0-dev.154", | ||
| "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.153" | ||
| "@mikro-orm/core": "7.0.0-dev.154" | ||
| } | ||
| } |
@@ -1,2 +0,2 @@ | ||
| import { type Dictionary, type EntityData, type EntityKey, type EntityMetadata, type EntityName, type EntityProperty, type FlatQueryOrderMap, LockMode, type QBFilterQuery, type QBQueryOrderMap, Raw, type RawQueryFragmentSymbol } from '@mikro-orm/core'; | ||
| import { type Dictionary, type EntityData, type EntityKey, type EntityMetadata, type EntityName, type EntityProperty, type FlatQueryOrderMap, type FormulaTable, LockMode, type QBFilterQuery, type QBQueryOrderMap, Raw, type RawQueryFragmentSymbol } from '@mikro-orm/core'; | ||
| import { JoinType, QueryType } from './enums.js'; | ||
@@ -19,3 +19,3 @@ import type { Field, JoinOptions } from '../typings.js'; | ||
| mapper(field: string | Raw | RawQueryFragmentSymbol, type?: QueryType): string; | ||
| mapper(field: string | Raw | RawQueryFragmentSymbol, type?: QueryType, value?: any, alias?: string | null): string; | ||
| mapper(field: string | Raw | RawQueryFragmentSymbol, type?: QueryType, value?: any, alias?: string | null, schema?: string): string; | ||
| processData(data: Dictionary, convertCustomTypes: boolean, multi?: boolean): any; | ||
@@ -63,2 +63,3 @@ joinOneToReference(prop: EntityProperty, ownerAlias: string, alias: string, type: JoinType, cond?: Dictionary, schema?: string): JoinOptions; | ||
| processOnConflictCondition(cond: QBFilterQuery, schema?: string): QBFilterQuery; | ||
| createFormulaTable(alias: string, meta: EntityMetadata, schema?: string): FormulaTable; | ||
| } | ||
@@ -65,0 +66,0 @@ export interface Alias<T> { |
@@ -24,3 +24,3 @@ import { ALIAS_REPLACEMENT, ALIAS_REPLACEMENT_RE, ArrayType, inspect, isRaw, LockMode, OptimisticLockError, QueryOperator, QueryOrderNumeric, raw, Raw, ReferenceKind, Utils, ValidationError, } from '@mikro-orm/core'; | ||
| } | ||
| mapper(field, type = QueryType.SELECT, value, alias) { | ||
| mapper(field, type = QueryType.SELECT, value, alias, schema) { | ||
| if (isRaw(field)) { | ||
@@ -87,3 +87,6 @@ return raw(field.sql, field.params); | ||
| const as = alias === null ? '' : ` as ${aliased}`; | ||
| let value = prop.formula(alias2); | ||
| const meta = this.aliasMap[a]?.meta ?? this.metadata.get(this.entityName); | ||
| const table = this.createFormulaTable(alias2, meta, schema); | ||
| const columns = meta.createColumnMappingObject(); | ||
| let value = prop.formula(table, columns); | ||
| if (!this.isTableNameAliasRequired(type)) { | ||
@@ -206,3 +209,6 @@ value = value.replaceAll(alias2 + '.', ''); | ||
| const alias = this.platform.quoteIdentifier(join.ownerAlias); | ||
| const left = join.prop.formula(alias); | ||
| const ownerMeta = this.aliasMap[join.ownerAlias]?.meta ?? this.metadata.get(this.entityName); | ||
| const table = this.createFormulaTable(alias.toString(), ownerMeta, schema); | ||
| const columns = ownerMeta.createColumnMappingObject(); | ||
| const left = join.prop.formula(table, columns); | ||
| conditions.push(`${left} = ${this.platform.quoteIdentifier(right)}`); | ||
@@ -779,2 +785,13 @@ return; | ||
| } | ||
| createFormulaTable(alias, meta, schema) { | ||
| const effectiveSchema = schema ?? (meta.schema !== '*' ? meta.schema : undefined); | ||
| const qualifiedName = effectiveSchema ? `${effectiveSchema}.${meta.tableName}` : meta.tableName; | ||
| return { | ||
| alias, | ||
| name: meta.tableName, | ||
| schema: effectiveSchema, | ||
| qualifiedName, | ||
| toString: () => alias, | ||
| }; | ||
| } | ||
| } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
815520
0.34%13383
0.34%37
5.71%