metal-orm 1.0.85 → 1.0.87

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/dist/index.d.cts CHANGED
@@ -1446,6 +1446,8 @@ interface ExpressionVisitor<R> {
1446
1446
  visitBetweenExpression?(node: BetweenExpressionNode): R;
1447
1447
  visitArithmeticExpression?(node: ArithmeticExpressionNode): R;
1448
1448
  visitBitwiseExpression?(node: BitwiseExpressionNode): R;
1449
+ visitOperand?(node: OperandNode): R;
1450
+ visitSelectQuery?(node: SelectQueryNode): R;
1449
1451
  otherwise?(node: ExpressionNode): R;
1450
1452
  }
1451
1453
  /**
@@ -1461,6 +1463,10 @@ interface OperandVisitor<R> {
1461
1463
  visitCaseExpression?(node: CaseExpressionNode): R;
1462
1464
  visitCast?(node: CastExpressionNode): R;
1463
1465
  visitWindowFunction?(node: WindowFunctionNode): R;
1466
+ visitArithmeticExpression?(node: ArithmeticExpressionNode): R;
1467
+ visitBitwiseExpression?(node: BitwiseExpressionNode): R;
1468
+ visitExpression?(node: ExpressionNode): R;
1469
+ visitSelectQuery?(node: SelectQueryNode): R;
1464
1470
  visitCollate?(node: CollateExpressionNode): R;
1465
1471
  visitAliasRef?(node: AliasRefNode): R;
1466
1472
  otherwise?(node: OperandNode): R;
@@ -1477,6 +1483,8 @@ declare const registerExpressionDispatcher: (type: string, dispatcher: Expressio
1477
1483
  * Allows new node kinds without modifying the core switch.
1478
1484
  */
1479
1485
  declare const registerOperandDispatcher: (type: string, dispatcher: OperandDispatch) => void;
1486
+ declare const hasExpressionDispatcher: (type: string) => boolean;
1487
+ declare const hasOperandDispatcher: (type: string) => boolean;
1480
1488
  /**
1481
1489
  * Clears all registered dispatchers. Primarily for tests.
1482
1490
  */
@@ -3972,6 +3980,9 @@ type SelectionValueType<TValue> = TValue extends TypedExpression<infer TRuntime>
3972
3980
  type SelectionResult<TSelection extends Record<string, ColumnSelectionValue>> = {
3973
3981
  [K in keyof TSelection]: SelectionValueType<TSelection[K]>;
3974
3982
  };
3983
+ type ParamOperandCompileOptions = {
3984
+ allowParamOperands?: boolean;
3985
+ };
3975
3986
  type SelectionFromKeys<TTable extends TableDef, K extends keyof TTable['columns'] & string> = Pick<InferRow<TTable>, K>;
3976
3987
  type DeepSelectEntry<TTable extends TableDef> = {
3977
3988
  type: 'root';
@@ -4565,7 +4576,7 @@ declare class SelectQueryBuilder<T = EntityInstance<TableDef>, TTable extends Ta
4565
4576
  * .compile('postgres');
4566
4577
  * console.log(compiled.sql); // SELECT "id", "name" FROM "users" WHERE "active" = true
4567
4578
  */
4568
- compile(dialect: SelectDialectInput): CompiledQuery;
4579
+ compile(dialect: SelectDialectInput, options?: ParamOperandCompileOptions): CompiledQuery;
4569
4580
  /**
4570
4581
  * Converts the query to SQL string for a specific dialect
4571
4582
  * @param dialect - Database dialect to generate SQL for
@@ -4576,7 +4587,7 @@ declare class SelectQueryBuilder<T = EntityInstance<TableDef>, TTable extends Ta
4576
4587
  * .toSql('postgres');
4577
4588
  * console.log(sql); // SELECT "id", "name" FROM "users" WHERE "active" = true
4578
4589
  */
4579
- toSql(dialect: SelectDialectInput): string;
4590
+ toSql(dialect: SelectDialectInput, options?: ParamOperandCompileOptions): string;
4580
4591
  /**
4581
4592
  * Gets hydration plan for query
4582
4593
  * @returns Hydration plan or undefined if none exists
@@ -7220,4 +7231,4 @@ type PooledExecutorFactoryOptions<TConn> = {
7220
7231
  */
7221
7232
  declare function createPooledExecutorFactory<TConn>(opts: PooledExecutorFactoryOptions<TConn>): DbExecutorFactory;
7222
7233
 
7223
- export { type AliasRefNode, type AnyDomainEvent, type ArithmeticExpressionNode, type TableRef as AstTableRef, AsyncLocalStorage, BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToManyRelation, type BelongsToOptions, type BelongsToReference, type BelongsToReferenceApi, type BelongsToRelation, type BetweenExpressionNode, type BinaryExpressionNode, type BitwiseExpressionNode, type CascadeMode, type CaseExpressionNode, type CastExpressionNode, type CheckConstraint, type CollateExpressionNode, Column, type ColumnDef, type ColumnDiff, type ColumnInput, type ColumnNode, type ColumnOptions, type ColumnRef, type ColumnSchemaOptions, type ColumnToTs, type ColumnType, ConstructorMaterializationStrategy, type CreateTediousClientOptions, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, type DbExecutor, type DbExecutorFactory, type DecoratedEntityInstance, DefaultBelongsToReference, DefaultEntityMaterializer, DefaultHasManyCollection, DefaultManyToManyCollection, type DefaultValue, DeleteQueryBuilder, type DialectName, type DomainEvent, DomainEventBus, type DomainEventHandler, Entity, type EntityContext, type EntityInstance, type EntityMaterializationStrategy, type EntityMaterializer, type EntityOptions, type PrimaryKey$1 as EntityPrimaryKey, EntityStatus, type ExecutionContext, type ExistsExpressionNode, type ExpressionNode, type ExpressionVisitor, type ForeignKeyReference, type FunctionNode, type GroupConcatOptions, type HasDomainEvents, HasMany, type HasManyCollection, type HasManyOptions, type HasManyRelation, HasOne, type HasOneOptions, type HasOneReference, type HasOneReferenceApi, type HasOneRelation, type HydrationContext, type HydrationMetadata, type HydrationPivotPlan, type HydrationPlan, type HydrationRelationPlan, type InExpressionNode, type InExpressionRight, type IndexColumn, type IndexDef, type InferRow, type InitialHandlers, type InputRelationMode, type InputSchemaMode, type InputSchemaOptions, InsertQueryBuilder, InterceptorPipeline, type IntrospectOptions, type JsonPathNode, type JsonSchemaFormat, type JsonSchemaProperty, type JsonSchemaType, type Jsonify, type JsonifyScalar, type LiteralNode, type LiteralValue, type LogicalExpressionNode, type ManyToManyCollection, type MssqlClientLike, MySqlDialect, type MysqlClientLike, type NullExpressionNode, type OpenApiParameter, type OpenApiSchema, type OpenApiSchemaBundle, type OperandNode, type OperandVisitor, Orm, type OrmDomainEvent, type OrmInterceptor, type OrmOptions, OrmSession, type OrmSessionOptions, type OutputSchemaOptions, type PaginatedResult, type ParamNode, type ParamProxy, type ParamProxyRoot, Pool, type PoolAdapter, type PoolLease, type PoolOptions, type PooledConnectionAdapter, type PostgresClientLike, PostgresDialect, PrimaryKey, type Primitive, PrototypeMaterializationStrategy, type QueryContext, type QueryInterceptor, type QueryLogEntry, type QueryLogger, type QueryResult, type RawDefaultValue, type ReferentialAction, type RelationChange, type RelationChangeEntry, type RelationDef, type RelationKey$1 as RelationKey, RelationKinds, type RelationMap, type RelationTargetTable, type RelationType, type RenderColumnOptions, STANDARD_COLUMN_TYPES, type SaveGraphInputPayload, type SaveGraphInputScalar, type SaveGraphJsonScalar, type SaveGraphSessionOptions, type ScalarSubqueryNode, type SchemaChange, type SchemaChangeKind, type SchemaDiffOptions, type SchemaExtractionContext, type SchemaGenerateResult, type SchemaIntrospector, type SchemaOptions, type SchemaPlan, SelectQueryBuilder, type SelectQueryInput, type SelectableKeys, type SimpleQueryRunner, SqlServerDialect, type SqliteClientLike, SqliteDialect, type StandardColumnType, type SynchronizeOptions, type TableDef, type TableHooks, type TableOptions, type TableRef$1 as TableRef, type TediousColumn, type TediousConnectionLike, type TediousModule, type TediousRequest, type TediousRequestCtor, type TediousTypes, type TrackedEntity, TypeScriptGenerator, type TypedExpression, type TypedLike, UpdateQueryBuilder, type ValueOperandInput, type WindowFunctionNode, abs, acos, add, addDomainEvent, age, aliasRef, and, arrayAppend, asType, ascii, asin, atan, atan2, avg, belongsTo, belongsToMany, between, bitAnd, bitLength, bitOr, bitXor, bootstrapEntities, buildFilterParameters, caseWhen, cast, cbrt, ceil, ceiling, char, charLength, chr, clearExpressionDispatchers, clearOperandDispatchers, coalesce, col, collate, columnOperand, concat, concatWs, correlateBy, cos, cot, count, countAll, createEntityFromRow, createEntityProxy, createExecutorFromQueryRunner, createMssqlExecutor, createMysqlExecutor, createParamProxy, createPooledExecutorFactory, createPostgresExecutor, createQueryLoggingExecutor, createSqliteExecutor, createTediousExecutor, createTediousMssqlClient, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, defineTable, degrees, deleteFrom, denseRank, diffSchema, div, endOfMonth, entityRef, entityRefs, eq, esel, executeHydrated, executeHydratedPlain, executeHydratedPlainWithContexts, executeHydratedWithContexts, executeSchemaSql, executeSchemaSqlFor, exists, exp, extract, extractSchema, firstValue, floor, fromUnixTime, generateCreateTableSql, generateSchemaSql, generateSchemaSqlFor, getColumn, getDecoratorMetadata, getSchemaIntrospector, getTableDefFromEntity, getTemporalFormat, greatest, groupConcat, gt, gte, hasMany, hasOne, hour, hydrateRows, ifNull, inList, inSubquery, initcap, insertInto, instr, introspectSchema, isCaseExpressionNode, isCastExpressionNode, isCollateExpressionNode, isExpressionSelectionNode, isFunctionNode, isNotNull, isNull, isOperandNode, isValueOperandInput, isWindowFunctionNode, jsonArrayAgg, jsonContains, jsonLength, jsonPath, jsonSet, jsonify, lag, lastValue, lead, least, left, length, like, ln, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, loadHasOneRelation, localTime, localTimestamp, locate, log, log10, log2, logBase, lower, lpad, lt, lte, ltrim, mapColumnType, mapRelationType, materializeAs, max, md5, min, minute, mod, month, mul, neq, normalizeColumnType, notBetween, notExists, notInList, notInSubquery, notLike, now, ntile, nullif, octetLength, or, outerRef, pi, position, pow, power, quarter, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, relationLoaderCache, renderColumnDefinition, renderTypeWithArgs, repeat, replace, reverse, right, round, rowNumber, rowsToQueryResult, rpad, rtrim, schemaToJson, second, sel, selectFrom, selectFromEntity, setRelations, sha1, sha2, shiftLeft, shiftRight, sign, sin, space, sqrt, stddev, sub, substr, sum, synchronizeSchema, tableRef, tan, toColumnRef, toTableRef, trim, trunc, truncate, unixTimestamp, update, upper, utcNow, valueToOperand, variance, visitExpression, visitOperand, weekOfYear, windowFunction, year };
7234
+ export { type AliasRefNode, type AnyDomainEvent, type ArithmeticExpressionNode, type TableRef as AstTableRef, AsyncLocalStorage, BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToManyRelation, type BelongsToOptions, type BelongsToReference, type BelongsToReferenceApi, type BelongsToRelation, type BetweenExpressionNode, type BinaryExpressionNode, type BitwiseExpressionNode, type CascadeMode, type CaseExpressionNode, type CastExpressionNode, type CheckConstraint, type CollateExpressionNode, Column, type ColumnDef, type ColumnDiff, type ColumnInput, type ColumnNode, type ColumnOptions, type ColumnRef, type ColumnSchemaOptions, type ColumnToTs, type ColumnType, ConstructorMaterializationStrategy, type CreateTediousClientOptions, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, type DbExecutor, type DbExecutorFactory, type DecoratedEntityInstance, DefaultBelongsToReference, DefaultEntityMaterializer, DefaultHasManyCollection, DefaultManyToManyCollection, type DefaultValue, DeleteQueryBuilder, type DialectName, type DomainEvent, DomainEventBus, type DomainEventHandler, Entity, type EntityContext, type EntityInstance, type EntityMaterializationStrategy, type EntityMaterializer, type EntityOptions, type PrimaryKey$1 as EntityPrimaryKey, EntityStatus, type ExecutionContext, type ExistsExpressionNode, type ExpressionNode, type ExpressionVisitor, type ForeignKeyReference, type FunctionNode, type GroupConcatOptions, type HasDomainEvents, HasMany, type HasManyCollection, type HasManyOptions, type HasManyRelation, HasOne, type HasOneOptions, type HasOneReference, type HasOneReferenceApi, type HasOneRelation, type HydrationContext, type HydrationMetadata, type HydrationPivotPlan, type HydrationPlan, type HydrationRelationPlan, type InExpressionNode, type InExpressionRight, type IndexColumn, type IndexDef, type InferRow, type InitialHandlers, type InputRelationMode, type InputSchemaMode, type InputSchemaOptions, InsertQueryBuilder, InterceptorPipeline, type IntrospectOptions, type JsonPathNode, type JsonSchemaFormat, type JsonSchemaProperty, type JsonSchemaType, type Jsonify, type JsonifyScalar, type LiteralNode, type LiteralValue, type LogicalExpressionNode, type ManyToManyCollection, type MssqlClientLike, MySqlDialect, type MysqlClientLike, type NullExpressionNode, type OpenApiParameter, type OpenApiSchema, type OpenApiSchemaBundle, type OperandNode, type OperandVisitor, Orm, type OrmDomainEvent, type OrmInterceptor, type OrmOptions, OrmSession, type OrmSessionOptions, type OutputSchemaOptions, type PaginatedResult, type ParamNode, type ParamProxy, type ParamProxyRoot, Pool, type PoolAdapter, type PoolLease, type PoolOptions, type PooledConnectionAdapter, type PostgresClientLike, PostgresDialect, PrimaryKey, type Primitive, PrototypeMaterializationStrategy, type QueryContext, type QueryInterceptor, type QueryLogEntry, type QueryLogger, type QueryResult, type RawDefaultValue, type ReferentialAction, type RelationChange, type RelationChangeEntry, type RelationDef, type RelationKey$1 as RelationKey, RelationKinds, type RelationMap, type RelationTargetTable, type RelationType, type RenderColumnOptions, STANDARD_COLUMN_TYPES, type SaveGraphInputPayload, type SaveGraphInputScalar, type SaveGraphJsonScalar, type SaveGraphSessionOptions, type ScalarSubqueryNode, type SchemaChange, type SchemaChangeKind, type SchemaDiffOptions, type SchemaExtractionContext, type SchemaGenerateResult, type SchemaIntrospector, type SchemaOptions, type SchemaPlan, SelectQueryBuilder, type SelectQueryInput, type SelectableKeys, type SimpleQueryRunner, SqlServerDialect, type SqliteClientLike, SqliteDialect, type StandardColumnType, type SynchronizeOptions, type TableDef, type TableHooks, type TableOptions, type TableRef$1 as TableRef, type TediousColumn, type TediousConnectionLike, type TediousModule, type TediousRequest, type TediousRequestCtor, type TediousTypes, type TrackedEntity, TypeScriptGenerator, type TypedExpression, type TypedLike, UpdateQueryBuilder, type ValueOperandInput, type WindowFunctionNode, abs, acos, add, addDomainEvent, age, aliasRef, and, arrayAppend, asType, ascii, asin, atan, atan2, avg, belongsTo, belongsToMany, between, bitAnd, bitLength, bitOr, bitXor, bootstrapEntities, buildFilterParameters, caseWhen, cast, cbrt, ceil, ceiling, char, charLength, chr, clearExpressionDispatchers, clearOperandDispatchers, coalesce, col, collate, columnOperand, concat, concatWs, correlateBy, cos, cot, count, countAll, createEntityFromRow, createEntityProxy, createExecutorFromQueryRunner, createMssqlExecutor, createMysqlExecutor, createParamProxy, createPooledExecutorFactory, createPostgresExecutor, createQueryLoggingExecutor, createSqliteExecutor, createTediousExecutor, createTediousMssqlClient, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, defineTable, degrees, deleteFrom, denseRank, diffSchema, div, endOfMonth, entityRef, entityRefs, eq, esel, executeHydrated, executeHydratedPlain, executeHydratedPlainWithContexts, executeHydratedWithContexts, executeSchemaSql, executeSchemaSqlFor, exists, exp, extract, extractSchema, firstValue, floor, fromUnixTime, generateCreateTableSql, generateSchemaSql, generateSchemaSqlFor, getColumn, getDecoratorMetadata, getSchemaIntrospector, getTableDefFromEntity, getTemporalFormat, greatest, groupConcat, gt, gte, hasExpressionDispatcher, hasMany, hasOne, hasOperandDispatcher, hour, hydrateRows, ifNull, inList, inSubquery, initcap, insertInto, instr, introspectSchema, isCaseExpressionNode, isCastExpressionNode, isCollateExpressionNode, isExpressionSelectionNode, isFunctionNode, isNotNull, isNull, isOperandNode, isValueOperandInput, isWindowFunctionNode, jsonArrayAgg, jsonContains, jsonLength, jsonPath, jsonSet, jsonify, lag, lastValue, lead, least, left, length, like, ln, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, loadHasOneRelation, localTime, localTimestamp, locate, log, log10, log2, logBase, lower, lpad, lt, lte, ltrim, mapColumnType, mapRelationType, materializeAs, max, md5, min, minute, mod, month, mul, neq, normalizeColumnType, notBetween, notExists, notInList, notInSubquery, notLike, now, ntile, nullif, octetLength, or, outerRef, pi, position, pow, power, quarter, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, relationLoaderCache, renderColumnDefinition, renderTypeWithArgs, repeat, replace, reverse, right, round, rowNumber, rowsToQueryResult, rpad, rtrim, schemaToJson, second, sel, selectFrom, selectFromEntity, setRelations, sha1, sha2, shiftLeft, shiftRight, sign, sin, space, sqrt, stddev, sub, substr, sum, synchronizeSchema, tableRef, tan, toColumnRef, toTableRef, trim, trunc, truncate, unixTimestamp, update, upper, utcNow, valueToOperand, variance, visitExpression, visitOperand, weekOfYear, windowFunction, year };
package/dist/index.d.ts CHANGED
@@ -1446,6 +1446,8 @@ interface ExpressionVisitor<R> {
1446
1446
  visitBetweenExpression?(node: BetweenExpressionNode): R;
1447
1447
  visitArithmeticExpression?(node: ArithmeticExpressionNode): R;
1448
1448
  visitBitwiseExpression?(node: BitwiseExpressionNode): R;
1449
+ visitOperand?(node: OperandNode): R;
1450
+ visitSelectQuery?(node: SelectQueryNode): R;
1449
1451
  otherwise?(node: ExpressionNode): R;
1450
1452
  }
1451
1453
  /**
@@ -1461,6 +1463,10 @@ interface OperandVisitor<R> {
1461
1463
  visitCaseExpression?(node: CaseExpressionNode): R;
1462
1464
  visitCast?(node: CastExpressionNode): R;
1463
1465
  visitWindowFunction?(node: WindowFunctionNode): R;
1466
+ visitArithmeticExpression?(node: ArithmeticExpressionNode): R;
1467
+ visitBitwiseExpression?(node: BitwiseExpressionNode): R;
1468
+ visitExpression?(node: ExpressionNode): R;
1469
+ visitSelectQuery?(node: SelectQueryNode): R;
1464
1470
  visitCollate?(node: CollateExpressionNode): R;
1465
1471
  visitAliasRef?(node: AliasRefNode): R;
1466
1472
  otherwise?(node: OperandNode): R;
@@ -1477,6 +1483,8 @@ declare const registerExpressionDispatcher: (type: string, dispatcher: Expressio
1477
1483
  * Allows new node kinds without modifying the core switch.
1478
1484
  */
1479
1485
  declare const registerOperandDispatcher: (type: string, dispatcher: OperandDispatch) => void;
1486
+ declare const hasExpressionDispatcher: (type: string) => boolean;
1487
+ declare const hasOperandDispatcher: (type: string) => boolean;
1480
1488
  /**
1481
1489
  * Clears all registered dispatchers. Primarily for tests.
1482
1490
  */
@@ -3972,6 +3980,9 @@ type SelectionValueType<TValue> = TValue extends TypedExpression<infer TRuntime>
3972
3980
  type SelectionResult<TSelection extends Record<string, ColumnSelectionValue>> = {
3973
3981
  [K in keyof TSelection]: SelectionValueType<TSelection[K]>;
3974
3982
  };
3983
+ type ParamOperandCompileOptions = {
3984
+ allowParamOperands?: boolean;
3985
+ };
3975
3986
  type SelectionFromKeys<TTable extends TableDef, K extends keyof TTable['columns'] & string> = Pick<InferRow<TTable>, K>;
3976
3987
  type DeepSelectEntry<TTable extends TableDef> = {
3977
3988
  type: 'root';
@@ -4565,7 +4576,7 @@ declare class SelectQueryBuilder<T = EntityInstance<TableDef>, TTable extends Ta
4565
4576
  * .compile('postgres');
4566
4577
  * console.log(compiled.sql); // SELECT "id", "name" FROM "users" WHERE "active" = true
4567
4578
  */
4568
- compile(dialect: SelectDialectInput): CompiledQuery;
4579
+ compile(dialect: SelectDialectInput, options?: ParamOperandCompileOptions): CompiledQuery;
4569
4580
  /**
4570
4581
  * Converts the query to SQL string for a specific dialect
4571
4582
  * @param dialect - Database dialect to generate SQL for
@@ -4576,7 +4587,7 @@ declare class SelectQueryBuilder<T = EntityInstance<TableDef>, TTable extends Ta
4576
4587
  * .toSql('postgres');
4577
4588
  * console.log(sql); // SELECT "id", "name" FROM "users" WHERE "active" = true
4578
4589
  */
4579
- toSql(dialect: SelectDialectInput): string;
4590
+ toSql(dialect: SelectDialectInput, options?: ParamOperandCompileOptions): string;
4580
4591
  /**
4581
4592
  * Gets hydration plan for query
4582
4593
  * @returns Hydration plan or undefined if none exists
@@ -7220,4 +7231,4 @@ type PooledExecutorFactoryOptions<TConn> = {
7220
7231
  */
7221
7232
  declare function createPooledExecutorFactory<TConn>(opts: PooledExecutorFactoryOptions<TConn>): DbExecutorFactory;
7222
7233
 
7223
- export { type AliasRefNode, type AnyDomainEvent, type ArithmeticExpressionNode, type TableRef as AstTableRef, AsyncLocalStorage, BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToManyRelation, type BelongsToOptions, type BelongsToReference, type BelongsToReferenceApi, type BelongsToRelation, type BetweenExpressionNode, type BinaryExpressionNode, type BitwiseExpressionNode, type CascadeMode, type CaseExpressionNode, type CastExpressionNode, type CheckConstraint, type CollateExpressionNode, Column, type ColumnDef, type ColumnDiff, type ColumnInput, type ColumnNode, type ColumnOptions, type ColumnRef, type ColumnSchemaOptions, type ColumnToTs, type ColumnType, ConstructorMaterializationStrategy, type CreateTediousClientOptions, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, type DbExecutor, type DbExecutorFactory, type DecoratedEntityInstance, DefaultBelongsToReference, DefaultEntityMaterializer, DefaultHasManyCollection, DefaultManyToManyCollection, type DefaultValue, DeleteQueryBuilder, type DialectName, type DomainEvent, DomainEventBus, type DomainEventHandler, Entity, type EntityContext, type EntityInstance, type EntityMaterializationStrategy, type EntityMaterializer, type EntityOptions, type PrimaryKey$1 as EntityPrimaryKey, EntityStatus, type ExecutionContext, type ExistsExpressionNode, type ExpressionNode, type ExpressionVisitor, type ForeignKeyReference, type FunctionNode, type GroupConcatOptions, type HasDomainEvents, HasMany, type HasManyCollection, type HasManyOptions, type HasManyRelation, HasOne, type HasOneOptions, type HasOneReference, type HasOneReferenceApi, type HasOneRelation, type HydrationContext, type HydrationMetadata, type HydrationPivotPlan, type HydrationPlan, type HydrationRelationPlan, type InExpressionNode, type InExpressionRight, type IndexColumn, type IndexDef, type InferRow, type InitialHandlers, type InputRelationMode, type InputSchemaMode, type InputSchemaOptions, InsertQueryBuilder, InterceptorPipeline, type IntrospectOptions, type JsonPathNode, type JsonSchemaFormat, type JsonSchemaProperty, type JsonSchemaType, type Jsonify, type JsonifyScalar, type LiteralNode, type LiteralValue, type LogicalExpressionNode, type ManyToManyCollection, type MssqlClientLike, MySqlDialect, type MysqlClientLike, type NullExpressionNode, type OpenApiParameter, type OpenApiSchema, type OpenApiSchemaBundle, type OperandNode, type OperandVisitor, Orm, type OrmDomainEvent, type OrmInterceptor, type OrmOptions, OrmSession, type OrmSessionOptions, type OutputSchemaOptions, type PaginatedResult, type ParamNode, type ParamProxy, type ParamProxyRoot, Pool, type PoolAdapter, type PoolLease, type PoolOptions, type PooledConnectionAdapter, type PostgresClientLike, PostgresDialect, PrimaryKey, type Primitive, PrototypeMaterializationStrategy, type QueryContext, type QueryInterceptor, type QueryLogEntry, type QueryLogger, type QueryResult, type RawDefaultValue, type ReferentialAction, type RelationChange, type RelationChangeEntry, type RelationDef, type RelationKey$1 as RelationKey, RelationKinds, type RelationMap, type RelationTargetTable, type RelationType, type RenderColumnOptions, STANDARD_COLUMN_TYPES, type SaveGraphInputPayload, type SaveGraphInputScalar, type SaveGraphJsonScalar, type SaveGraphSessionOptions, type ScalarSubqueryNode, type SchemaChange, type SchemaChangeKind, type SchemaDiffOptions, type SchemaExtractionContext, type SchemaGenerateResult, type SchemaIntrospector, type SchemaOptions, type SchemaPlan, SelectQueryBuilder, type SelectQueryInput, type SelectableKeys, type SimpleQueryRunner, SqlServerDialect, type SqliteClientLike, SqliteDialect, type StandardColumnType, type SynchronizeOptions, type TableDef, type TableHooks, type TableOptions, type TableRef$1 as TableRef, type TediousColumn, type TediousConnectionLike, type TediousModule, type TediousRequest, type TediousRequestCtor, type TediousTypes, type TrackedEntity, TypeScriptGenerator, type TypedExpression, type TypedLike, UpdateQueryBuilder, type ValueOperandInput, type WindowFunctionNode, abs, acos, add, addDomainEvent, age, aliasRef, and, arrayAppend, asType, ascii, asin, atan, atan2, avg, belongsTo, belongsToMany, between, bitAnd, bitLength, bitOr, bitXor, bootstrapEntities, buildFilterParameters, caseWhen, cast, cbrt, ceil, ceiling, char, charLength, chr, clearExpressionDispatchers, clearOperandDispatchers, coalesce, col, collate, columnOperand, concat, concatWs, correlateBy, cos, cot, count, countAll, createEntityFromRow, createEntityProxy, createExecutorFromQueryRunner, createMssqlExecutor, createMysqlExecutor, createParamProxy, createPooledExecutorFactory, createPostgresExecutor, createQueryLoggingExecutor, createSqliteExecutor, createTediousExecutor, createTediousMssqlClient, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, defineTable, degrees, deleteFrom, denseRank, diffSchema, div, endOfMonth, entityRef, entityRefs, eq, esel, executeHydrated, executeHydratedPlain, executeHydratedPlainWithContexts, executeHydratedWithContexts, executeSchemaSql, executeSchemaSqlFor, exists, exp, extract, extractSchema, firstValue, floor, fromUnixTime, generateCreateTableSql, generateSchemaSql, generateSchemaSqlFor, getColumn, getDecoratorMetadata, getSchemaIntrospector, getTableDefFromEntity, getTemporalFormat, greatest, groupConcat, gt, gte, hasMany, hasOne, hour, hydrateRows, ifNull, inList, inSubquery, initcap, insertInto, instr, introspectSchema, isCaseExpressionNode, isCastExpressionNode, isCollateExpressionNode, isExpressionSelectionNode, isFunctionNode, isNotNull, isNull, isOperandNode, isValueOperandInput, isWindowFunctionNode, jsonArrayAgg, jsonContains, jsonLength, jsonPath, jsonSet, jsonify, lag, lastValue, lead, least, left, length, like, ln, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, loadHasOneRelation, localTime, localTimestamp, locate, log, log10, log2, logBase, lower, lpad, lt, lte, ltrim, mapColumnType, mapRelationType, materializeAs, max, md5, min, minute, mod, month, mul, neq, normalizeColumnType, notBetween, notExists, notInList, notInSubquery, notLike, now, ntile, nullif, octetLength, or, outerRef, pi, position, pow, power, quarter, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, relationLoaderCache, renderColumnDefinition, renderTypeWithArgs, repeat, replace, reverse, right, round, rowNumber, rowsToQueryResult, rpad, rtrim, schemaToJson, second, sel, selectFrom, selectFromEntity, setRelations, sha1, sha2, shiftLeft, shiftRight, sign, sin, space, sqrt, stddev, sub, substr, sum, synchronizeSchema, tableRef, tan, toColumnRef, toTableRef, trim, trunc, truncate, unixTimestamp, update, upper, utcNow, valueToOperand, variance, visitExpression, visitOperand, weekOfYear, windowFunction, year };
7234
+ export { type AliasRefNode, type AnyDomainEvent, type ArithmeticExpressionNode, type TableRef as AstTableRef, AsyncLocalStorage, BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToManyRelation, type BelongsToOptions, type BelongsToReference, type BelongsToReferenceApi, type BelongsToRelation, type BetweenExpressionNode, type BinaryExpressionNode, type BitwiseExpressionNode, type CascadeMode, type CaseExpressionNode, type CastExpressionNode, type CheckConstraint, type CollateExpressionNode, Column, type ColumnDef, type ColumnDiff, type ColumnInput, type ColumnNode, type ColumnOptions, type ColumnRef, type ColumnSchemaOptions, type ColumnToTs, type ColumnType, ConstructorMaterializationStrategy, type CreateTediousClientOptions, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, type DbExecutor, type DbExecutorFactory, type DecoratedEntityInstance, DefaultBelongsToReference, DefaultEntityMaterializer, DefaultHasManyCollection, DefaultManyToManyCollection, type DefaultValue, DeleteQueryBuilder, type DialectName, type DomainEvent, DomainEventBus, type DomainEventHandler, Entity, type EntityContext, type EntityInstance, type EntityMaterializationStrategy, type EntityMaterializer, type EntityOptions, type PrimaryKey$1 as EntityPrimaryKey, EntityStatus, type ExecutionContext, type ExistsExpressionNode, type ExpressionNode, type ExpressionVisitor, type ForeignKeyReference, type FunctionNode, type GroupConcatOptions, type HasDomainEvents, HasMany, type HasManyCollection, type HasManyOptions, type HasManyRelation, HasOne, type HasOneOptions, type HasOneReference, type HasOneReferenceApi, type HasOneRelation, type HydrationContext, type HydrationMetadata, type HydrationPivotPlan, type HydrationPlan, type HydrationRelationPlan, type InExpressionNode, type InExpressionRight, type IndexColumn, type IndexDef, type InferRow, type InitialHandlers, type InputRelationMode, type InputSchemaMode, type InputSchemaOptions, InsertQueryBuilder, InterceptorPipeline, type IntrospectOptions, type JsonPathNode, type JsonSchemaFormat, type JsonSchemaProperty, type JsonSchemaType, type Jsonify, type JsonifyScalar, type LiteralNode, type LiteralValue, type LogicalExpressionNode, type ManyToManyCollection, type MssqlClientLike, MySqlDialect, type MysqlClientLike, type NullExpressionNode, type OpenApiParameter, type OpenApiSchema, type OpenApiSchemaBundle, type OperandNode, type OperandVisitor, Orm, type OrmDomainEvent, type OrmInterceptor, type OrmOptions, OrmSession, type OrmSessionOptions, type OutputSchemaOptions, type PaginatedResult, type ParamNode, type ParamProxy, type ParamProxyRoot, Pool, type PoolAdapter, type PoolLease, type PoolOptions, type PooledConnectionAdapter, type PostgresClientLike, PostgresDialect, PrimaryKey, type Primitive, PrototypeMaterializationStrategy, type QueryContext, type QueryInterceptor, type QueryLogEntry, type QueryLogger, type QueryResult, type RawDefaultValue, type ReferentialAction, type RelationChange, type RelationChangeEntry, type RelationDef, type RelationKey$1 as RelationKey, RelationKinds, type RelationMap, type RelationTargetTable, type RelationType, type RenderColumnOptions, STANDARD_COLUMN_TYPES, type SaveGraphInputPayload, type SaveGraphInputScalar, type SaveGraphJsonScalar, type SaveGraphSessionOptions, type ScalarSubqueryNode, type SchemaChange, type SchemaChangeKind, type SchemaDiffOptions, type SchemaExtractionContext, type SchemaGenerateResult, type SchemaIntrospector, type SchemaOptions, type SchemaPlan, SelectQueryBuilder, type SelectQueryInput, type SelectableKeys, type SimpleQueryRunner, SqlServerDialect, type SqliteClientLike, SqliteDialect, type StandardColumnType, type SynchronizeOptions, type TableDef, type TableHooks, type TableOptions, type TableRef$1 as TableRef, type TediousColumn, type TediousConnectionLike, type TediousModule, type TediousRequest, type TediousRequestCtor, type TediousTypes, type TrackedEntity, TypeScriptGenerator, type TypedExpression, type TypedLike, UpdateQueryBuilder, type ValueOperandInput, type WindowFunctionNode, abs, acos, add, addDomainEvent, age, aliasRef, and, arrayAppend, asType, ascii, asin, atan, atan2, avg, belongsTo, belongsToMany, between, bitAnd, bitLength, bitOr, bitXor, bootstrapEntities, buildFilterParameters, caseWhen, cast, cbrt, ceil, ceiling, char, charLength, chr, clearExpressionDispatchers, clearOperandDispatchers, coalesce, col, collate, columnOperand, concat, concatWs, correlateBy, cos, cot, count, countAll, createEntityFromRow, createEntityProxy, createExecutorFromQueryRunner, createMssqlExecutor, createMysqlExecutor, createParamProxy, createPooledExecutorFactory, createPostgresExecutor, createQueryLoggingExecutor, createSqliteExecutor, createTediousExecutor, createTediousMssqlClient, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, defineTable, degrees, deleteFrom, denseRank, diffSchema, div, endOfMonth, entityRef, entityRefs, eq, esel, executeHydrated, executeHydratedPlain, executeHydratedPlainWithContexts, executeHydratedWithContexts, executeSchemaSql, executeSchemaSqlFor, exists, exp, extract, extractSchema, firstValue, floor, fromUnixTime, generateCreateTableSql, generateSchemaSql, generateSchemaSqlFor, getColumn, getDecoratorMetadata, getSchemaIntrospector, getTableDefFromEntity, getTemporalFormat, greatest, groupConcat, gt, gte, hasExpressionDispatcher, hasMany, hasOne, hasOperandDispatcher, hour, hydrateRows, ifNull, inList, inSubquery, initcap, insertInto, instr, introspectSchema, isCaseExpressionNode, isCastExpressionNode, isCollateExpressionNode, isExpressionSelectionNode, isFunctionNode, isNotNull, isNull, isOperandNode, isValueOperandInput, isWindowFunctionNode, jsonArrayAgg, jsonContains, jsonLength, jsonPath, jsonSet, jsonify, lag, lastValue, lead, least, left, length, like, ln, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, loadHasOneRelation, localTime, localTimestamp, locate, log, log10, log2, logBase, lower, lpad, lt, lte, ltrim, mapColumnType, mapRelationType, materializeAs, max, md5, min, minute, mod, month, mul, neq, normalizeColumnType, notBetween, notExists, notInList, notInSubquery, notLike, now, ntile, nullif, octetLength, or, outerRef, pi, position, pow, power, quarter, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, relationLoaderCache, renderColumnDefinition, renderTypeWithArgs, repeat, replace, reverse, right, round, rowNumber, rowsToQueryResult, rpad, rtrim, schemaToJson, second, sel, selectFrom, selectFromEntity, setRelations, sha1, sha2, shiftLeft, shiftRight, sign, sin, space, sqrt, stddev, sub, substr, sum, synchronizeSchema, tableRef, tan, toColumnRef, toTableRef, trim, trunc, truncate, unixTimestamp, update, upper, utcNow, valueToOperand, variance, visitExpression, visitOperand, weekOfYear, windowFunction, year };
package/dist/index.js CHANGED
@@ -770,6 +770,8 @@ var registerExpressionDispatcher = (type, dispatcher) => {
770
770
  var registerOperandDispatcher = (type, dispatcher) => {
771
771
  operandRegistry = operandRegistry.register(type, dispatcher);
772
772
  };
773
+ var hasExpressionDispatcher = (type) => expressionRegistry.get(type) !== void 0;
774
+ var hasOperandDispatcher = (type) => operandRegistry.get(type) !== void 0;
773
775
  var clearExpressionDispatchers = () => {
774
776
  expressionRegistry = expressionRegistry.clear();
775
777
  };
@@ -864,6 +866,12 @@ var visitOperand = (node, visitor) => {
864
866
  case "Collate":
865
867
  if (visitor.visitCollate) return visitor.visitCollate(node);
866
868
  break;
869
+ case "ArithmeticExpression":
870
+ if (visitor.visitArithmeticExpression) return visitor.visitArithmeticExpression(node);
871
+ break;
872
+ case "BitwiseExpression":
873
+ if (visitor.visitBitwiseExpression) return visitor.visitBitwiseExpression(node);
874
+ break;
867
875
  default:
868
876
  break;
869
877
  }
@@ -7367,7 +7375,7 @@ var collectFilterColumns = (expr, table, rootTables) => {
7367
7375
  columns.add(node.name);
7368
7376
  }
7369
7377
  };
7370
- const visitOrderingTerm2 = (term) => {
7378
+ const visitOrderingTerm = (term) => {
7371
7379
  if (!term || typeof term !== "object") return;
7372
7380
  if (isOperandNode(term)) {
7373
7381
  visitOperand2(term);
@@ -7379,7 +7387,7 @@ var collectFilterColumns = (expr, table, rootTables) => {
7379
7387
  };
7380
7388
  const visitOrderBy = (orderBy) => {
7381
7389
  if (!orderBy) return;
7382
- orderBy.forEach((node) => visitOrderingTerm2(node.term));
7390
+ orderBy.forEach((node) => visitOrderingTerm(node.term));
7383
7391
  };
7384
7392
  const visitOperand2 = (node) => {
7385
7393
  switch (node.type) {
@@ -7531,137 +7539,174 @@ var getNodeType3 = (value) => {
7531
7539
  }
7532
7540
  return void 0;
7533
7541
  };
7534
- var visitOrderingTerm = (term, visitor) => {
7535
- if (isOperandNode(term)) {
7536
- visitOperandNode(term, visitor);
7537
- return;
7538
- }
7539
- visitExpressionNode(term, visitor);
7540
- };
7541
- var visitOrderByNode = (node, visitor) => {
7542
- visitor.visitOrderBy?.(node);
7543
- visitOrderingTerm(node.term, visitor);
7544
- };
7545
- var visitTableSource = (source, visitor) => {
7546
- visitor.visitTableSource?.(source);
7547
- if (source.type === "DerivedTable") {
7548
- visitor.visitDerivedTable?.(source);
7549
- visitSelectQuery(source.query, visitor);
7550
- return;
7551
- }
7552
- if (source.type === "FunctionTable") {
7553
- visitor.visitFunctionTable?.(source);
7554
- source.args?.forEach((arg) => visitOperandNode(arg, visitor));
7555
- }
7556
- };
7557
- var visitExpressionNode = (node, visitor) => {
7558
- visitor.visitExpression?.(node);
7559
- const type = getNodeType3(node);
7560
- if (!type) return;
7561
- switch (type) {
7562
- case "BinaryExpression":
7563
- visitOperandNode(node.left, visitor);
7564
- visitOperandNode(node.right, visitor);
7565
- if (node.escape) {
7566
- visitOperandNode(node.escape, visitor);
7567
- }
7542
+ var visitSelectQuery = (ast, visitor) => {
7543
+ const visitExpressionNode = (node) => {
7544
+ visitExpression(node, expressionVisitor);
7545
+ };
7546
+ const visitOperandNode = (node) => {
7547
+ visitOperand(node, operandVisitor);
7548
+ };
7549
+ const visitOrderingTerm = (term) => {
7550
+ if (!term || typeof term !== "object") return;
7551
+ if (isOperandNode(term)) {
7552
+ visitOperandNode(term);
7568
7553
  return;
7569
- case "LogicalExpression":
7570
- node.operands.forEach((operand) => visitExpressionNode(operand, visitor));
7554
+ }
7555
+ const type = getNodeType3(term);
7556
+ if (type && hasOperandDispatcher(type)) {
7557
+ visitOperandNode(term);
7571
7558
  return;
7572
- case "NullExpression":
7573
- visitOperandNode(node.left, visitor);
7559
+ }
7560
+ if (type) {
7561
+ visitExpressionNode(term);
7562
+ }
7563
+ };
7564
+ const visitOrderByNode = (node) => {
7565
+ visitor.visitOrderBy?.(node);
7566
+ visitOrderingTerm(node.term);
7567
+ };
7568
+ const visitTableSource = (source) => {
7569
+ visitor.visitTableSource?.(source);
7570
+ if (source.type === "DerivedTable") {
7571
+ visitor.visitDerivedTable?.(source);
7572
+ visitSelectQuery(source.query, visitor);
7574
7573
  return;
7575
- case "InExpression":
7576
- visitOperandNode(node.left, visitor);
7574
+ }
7575
+ if (source.type === "FunctionTable") {
7576
+ visitor.visitFunctionTable?.(source);
7577
+ source.args?.forEach((arg) => visitOperandNode(arg));
7578
+ }
7579
+ };
7580
+ const expressionVisitor = {
7581
+ visitBinaryExpression: (node) => {
7582
+ visitor.visitExpression?.(node);
7583
+ visitOperandNode(node.left);
7584
+ visitOperandNode(node.right);
7585
+ if (node.escape) {
7586
+ visitOperandNode(node.escape);
7587
+ }
7588
+ },
7589
+ visitLogicalExpression: (node) => {
7590
+ visitor.visitExpression?.(node);
7591
+ node.operands.forEach((operand) => visitExpressionNode(operand));
7592
+ },
7593
+ visitNullExpression: (node) => {
7594
+ visitor.visitExpression?.(node);
7595
+ visitOperandNode(node.left);
7596
+ },
7597
+ visitInExpression: (node) => {
7598
+ visitor.visitExpression?.(node);
7599
+ visitOperandNode(node.left);
7577
7600
  if (Array.isArray(node.right)) {
7578
- node.right.forEach((operand) => visitOperandNode(operand, visitor));
7601
+ node.right.forEach((operand) => visitOperandNode(operand));
7579
7602
  } else {
7580
- visitOperandNode(node.right, visitor);
7603
+ visitOperandNode(node.right);
7581
7604
  }
7582
- return;
7583
- case "ExistsExpression":
7605
+ },
7606
+ visitExistsExpression: (node) => {
7607
+ visitor.visitExpression?.(node);
7584
7608
  visitSelectQuery(node.subquery, visitor);
7585
- return;
7586
- case "BetweenExpression":
7587
- visitOperandNode(node.left, visitor);
7588
- visitOperandNode(node.lower, visitor);
7589
- visitOperandNode(node.upper, visitor);
7590
- return;
7591
- case "ArithmeticExpression":
7592
- visitOperandNode(node.left, visitor);
7593
- visitOperandNode(node.right, visitor);
7594
- return;
7595
- case "BitwiseExpression":
7596
- visitOperandNode(node.left, visitor);
7597
- visitOperandNode(node.right, visitor);
7598
- return;
7599
- default: {
7600
- return;
7609
+ },
7610
+ visitBetweenExpression: (node) => {
7611
+ visitor.visitExpression?.(node);
7612
+ visitOperandNode(node.left);
7613
+ visitOperandNode(node.lower);
7614
+ visitOperandNode(node.upper);
7615
+ },
7616
+ visitArithmeticExpression: (node) => {
7617
+ visitor.visitExpression?.(node);
7618
+ visitOperandNode(node.left);
7619
+ visitOperandNode(node.right);
7620
+ },
7621
+ visitBitwiseExpression: (node) => {
7622
+ visitor.visitExpression?.(node);
7623
+ visitOperandNode(node.left);
7624
+ visitOperandNode(node.right);
7625
+ },
7626
+ visitOperand: (node) => {
7627
+ visitOperandNode(node);
7628
+ },
7629
+ visitSelectQuery: (node) => {
7630
+ visitSelectQuery(node, visitor);
7631
+ },
7632
+ otherwise: (node) => {
7633
+ visitor.visitExpression?.(node);
7601
7634
  }
7602
- }
7603
- };
7604
- var visitOperandNode = (node, visitor) => {
7605
- visitor.visitOperand?.(node);
7606
- const type = getNodeType3(node);
7607
- if (type === "Param") {
7608
- visitor.visitParam?.(node);
7609
- }
7610
- if (!type) return;
7611
- switch (type) {
7612
- case "Column":
7613
- case "Literal":
7614
- case "Param":
7615
- case "AliasRef":
7616
- return;
7617
- case "Function":
7618
- node.args?.forEach((arg) => visitOperandNode(arg, visitor));
7619
- node.orderBy?.forEach((order) => visitOrderByNode(order, visitor));
7635
+ };
7636
+ const operandVisitor = {
7637
+ visitColumn: (node) => {
7638
+ visitor.visitOperand?.(node);
7639
+ },
7640
+ visitLiteral: (node) => {
7641
+ visitor.visitOperand?.(node);
7642
+ },
7643
+ visitParam: (node) => {
7644
+ visitor.visitOperand?.(node);
7645
+ visitor.visitParam?.(node);
7646
+ },
7647
+ visitFunction: (node) => {
7648
+ visitor.visitOperand?.(node);
7649
+ node.args?.forEach((arg) => visitOperandNode(arg));
7650
+ node.orderBy?.forEach((order) => visitOrderByNode(order));
7620
7651
  if (node.separator) {
7621
- visitOperandNode(node.separator, visitor);
7652
+ visitOperandNode(node.separator);
7622
7653
  }
7623
- return;
7624
- case "JsonPath":
7625
- visitOperandNode(node.column, visitor);
7626
- return;
7627
- case "ScalarSubquery":
7654
+ },
7655
+ visitJsonPath: (node) => {
7656
+ visitor.visitOperand?.(node);
7657
+ visitOperandNode(node.column);
7658
+ },
7659
+ visitScalarSubquery: (node) => {
7660
+ visitor.visitOperand?.(node);
7628
7661
  visitSelectQuery(node.query, visitor);
7629
- return;
7630
- case "CaseExpression":
7662
+ },
7663
+ visitCaseExpression: (node) => {
7664
+ visitor.visitOperand?.(node);
7631
7665
  node.conditions.forEach((cond) => {
7632
- visitExpressionNode(cond.when, visitor);
7633
- visitOperandNode(cond.then, visitor);
7666
+ visitExpressionNode(cond.when);
7667
+ visitOperandNode(cond.then);
7634
7668
  });
7635
7669
  if (node.else) {
7636
- visitOperandNode(node.else, visitor);
7670
+ visitOperandNode(node.else);
7637
7671
  }
7638
- return;
7639
- case "Cast":
7640
- visitOperandNode(node.expression, visitor);
7641
- return;
7642
- case "WindowFunction":
7643
- node.args?.forEach((arg) => visitOperandNode(arg, visitor));
7644
- node.partitionBy?.forEach((term) => visitOperandNode(term, visitor));
7645
- node.orderBy?.forEach((order) => visitOrderByNode(order, visitor));
7646
- return;
7647
- case "ArithmeticExpression":
7648
- visitOperandNode(node.left, visitor);
7649
- visitOperandNode(node.right, visitor);
7650
- return;
7651
- case "BitwiseExpression":
7652
- visitOperandNode(node.left, visitor);
7653
- visitOperandNode(node.right, visitor);
7654
- return;
7655
- case "Collate":
7656
- visitOperandNode(node.expression, visitor);
7657
- return;
7658
- default: {
7659
- const _exhaustive = node;
7660
- return _exhaustive;
7672
+ },
7673
+ visitCast: (node) => {
7674
+ visitor.visitOperand?.(node);
7675
+ visitOperandNode(node.expression);
7676
+ },
7677
+ visitWindowFunction: (node) => {
7678
+ visitor.visitOperand?.(node);
7679
+ node.args?.forEach((arg) => visitOperandNode(arg));
7680
+ node.partitionBy?.forEach((term) => visitOperandNode(term));
7681
+ node.orderBy?.forEach((order) => visitOrderByNode(order));
7682
+ },
7683
+ visitArithmeticExpression: (node) => {
7684
+ visitor.visitOperand?.(node);
7685
+ visitOperandNode(node.left);
7686
+ visitOperandNode(node.right);
7687
+ },
7688
+ visitBitwiseExpression: (node) => {
7689
+ visitor.visitOperand?.(node);
7690
+ visitOperandNode(node.left);
7691
+ visitOperandNode(node.right);
7692
+ },
7693
+ visitExpression: (node) => {
7694
+ visitExpressionNode(node);
7695
+ },
7696
+ visitSelectQuery: (node) => {
7697
+ visitSelectQuery(node, visitor);
7698
+ },
7699
+ visitCollate: (node) => {
7700
+ visitor.visitOperand?.(node);
7701
+ visitOperandNode(node.expression);
7702
+ },
7703
+ visitAliasRef: (node) => {
7704
+ visitor.visitOperand?.(node);
7705
+ },
7706
+ otherwise: (node) => {
7707
+ visitor.visitOperand?.(node);
7661
7708
  }
7662
- }
7663
- };
7664
- var visitSelectQuery = (ast, visitor) => {
7709
+ };
7665
7710
  visitor.visitSelectQuery?.(ast);
7666
7711
  if (ast.ctes) {
7667
7712
  for (const cte of ast.ctes) {
@@ -7669,29 +7714,29 @@ var visitSelectQuery = (ast, visitor) => {
7669
7714
  visitSelectQuery(cte.query, visitor);
7670
7715
  }
7671
7716
  }
7672
- visitTableSource(ast.from, visitor);
7717
+ visitTableSource(ast.from);
7673
7718
  ast.columns?.forEach((col2) => {
7674
- visitOperandNode(col2, visitor);
7719
+ visitOperandNode(col2);
7675
7720
  });
7676
7721
  ast.joins?.forEach((join) => {
7677
7722
  visitor.visitJoin?.(join);
7678
- visitTableSource(join.table, visitor);
7679
- visitExpressionNode(join.condition, visitor);
7723
+ visitTableSource(join.table);
7724
+ visitExpressionNode(join.condition);
7680
7725
  });
7681
7726
  if (ast.where) {
7682
- visitExpressionNode(ast.where, visitor);
7727
+ visitExpressionNode(ast.where);
7683
7728
  }
7684
7729
  ast.groupBy?.forEach((term) => {
7685
- visitOrderingTerm(term, visitor);
7730
+ visitOrderingTerm(term);
7686
7731
  });
7687
7732
  if (ast.having) {
7688
- visitExpressionNode(ast.having, visitor);
7733
+ visitExpressionNode(ast.having);
7689
7734
  }
7690
7735
  ast.orderBy?.forEach((order) => {
7691
- visitOrderByNode(order, visitor);
7736
+ visitOrderByNode(order);
7692
7737
  });
7693
7738
  ast.distinct?.forEach((col2) => {
7694
- visitOperandNode(col2, visitor);
7739
+ visitOperandNode(col2);
7695
7740
  });
7696
7741
  ast.setOps?.forEach((op) => {
7697
7742
  visitor.visitSetOperation?.(op);
@@ -7700,14 +7745,16 @@ var visitSelectQuery = (ast, visitor) => {
7700
7745
  };
7701
7746
 
7702
7747
  // src/core/ast/ast-validation.ts
7703
- var hasParamOperandsInQuery = (ast) => {
7704
- let hasParams = false;
7748
+ var findFirstParamOperandName = (ast) => {
7749
+ let name;
7705
7750
  visitSelectQuery(ast, {
7706
- visitParam: () => {
7707
- hasParams = true;
7751
+ visitParam: (node) => {
7752
+ if (!name) {
7753
+ name = node.name;
7754
+ }
7708
7755
  }
7709
7756
  });
7710
- return hasParams;
7757
+ return name;
7711
7758
  };
7712
7759
 
7713
7760
  // src/query-builder/select.ts
@@ -8189,9 +8236,9 @@ var SelectQueryBuilder = class _SelectQueryBuilder {
8189
8236
  */
8190
8237
  validateNoParamOperands() {
8191
8238
  const ast = this.context.hydration.applyToAst(this.context.state.ast);
8192
- const hasParams = hasParamOperandsInQuery(ast);
8193
- if (hasParams) {
8194
- throw new Error("Cannot execute query containing Param operands. Param proxies are only for schema generation (getSchema()). If you need real parameters, use literal values.");
8239
+ const paramName = findFirstParamOperandName(ast);
8240
+ if (paramName) {
8241
+ throw new Error(`Cannot execute query containing Param operand "${paramName}". Param proxies are only for schema generation (getSchema()). If you need real parameters, use literal values.`);
8195
8242
  }
8196
8243
  }
8197
8244
  /**
@@ -8518,9 +8565,17 @@ var SelectQueryBuilder = class _SelectQueryBuilder {
8518
8565
  * .compile('postgres');
8519
8566
  * console.log(compiled.sql); // SELECT "id", "name" FROM "users" WHERE "active" = true
8520
8567
  */
8521
- compile(dialect) {
8568
+ compile(dialect, options) {
8522
8569
  const resolved = resolveDialectInput(dialect);
8523
- return resolved.compileSelect(this.getAST());
8570
+ const ast = this.getAST();
8571
+ if (!options?.allowParamOperands) {
8572
+ const paramName = findFirstParamOperandName(ast);
8573
+ if (paramName) {
8574
+ throw new Error(`Cannot compile query containing Param operand "${paramName}". Param proxies are only for schema generation (getSchema()). If you need real parameters, use literal values.`);
8575
+ }
8576
+ return resolved.compileSelect(ast);
8577
+ }
8578
+ return resolved.compileSelectWithOptions(ast, { allowParams: true });
8524
8579
  }
8525
8580
  /**
8526
8581
  * Converts the query to SQL string for a specific dialect
@@ -8532,8 +8587,8 @@ var SelectQueryBuilder = class _SelectQueryBuilder {
8532
8587
  * .toSql('postgres');
8533
8588
  * console.log(sql); // SELECT "id", "name" FROM "users" WHERE "active" = true
8534
8589
  */
8535
- toSql(dialect) {
8536
- return this.compile(dialect).sql;
8590
+ toSql(dialect, options) {
8591
+ return this.compile(dialect, options).sql;
8537
8592
  }
8538
8593
  /**
8539
8594
  * Gets hydration plan for query
@@ -14221,8 +14276,10 @@ export {
14221
14276
  groupConcat,
14222
14277
  gt,
14223
14278
  gte,
14279
+ hasExpressionDispatcher,
14224
14280
  hasMany,
14225
14281
  hasOne,
14282
+ hasOperandDispatcher,
14226
14283
  hour,
14227
14284
  hydrateRows,
14228
14285
  ifNull,