metal-orm 1.0.46 → 1.0.47
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.cjs +1037 -336
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -6
- package/dist/index.d.ts +28 -6
- package/dist/index.js +1035 -336
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/scripts/generate-entities.mjs +36 -9
- package/src/codegen/typescript.ts +22 -10
- package/src/core/ast/expression-builders.ts +13 -0
- package/src/core/ast/expression-nodes.ts +25 -5
- package/src/core/ast/expression-visitor.ts +5 -0
- package/src/core/ast/query.ts +9 -1
- package/src/core/ddl/introspect/catalogs/index.ts +4 -1
- package/src/core/ddl/introspect/catalogs/mssql.ts +126 -0
- package/src/core/ddl/introspect/catalogs/mysql.ts +89 -0
- package/src/core/ddl/introspect/catalogs/sqlite.ts +47 -0
- package/src/core/ddl/introspect/functions/mssql.ts +84 -0
- package/src/core/ddl/introspect/mssql.ts +471 -210
- package/src/core/ddl/introspect/mysql.ts +336 -125
- package/src/core/ddl/introspect/postgres.ts +44 -5
- package/src/core/ddl/introspect/run-select.ts +3 -8
- package/src/core/ddl/introspect/sqlite.ts +113 -60
- package/src/core/ddl/schema-types.ts +2 -1
- package/src/core/dialect/abstract.ts +12 -1
- package/src/core/dialect/mssql/index.ts +4 -10
- package/src/query-builder/query-ast-service.ts +3 -3
- package/src/query-builder/select-query-state.ts +2 -0
package/dist/index.d.cts
CHANGED
|
@@ -689,6 +689,18 @@ interface CaseExpressionNode {
|
|
|
689
689
|
/** Optional alias for the result */
|
|
690
690
|
alias?: string;
|
|
691
691
|
}
|
|
692
|
+
/**
|
|
693
|
+
* AST node representing a CAST expression (CAST(value AS type)).
|
|
694
|
+
*/
|
|
695
|
+
interface CastExpressionNode {
|
|
696
|
+
type: 'Cast';
|
|
697
|
+
/** Expression being cast */
|
|
698
|
+
expression: OperandNode;
|
|
699
|
+
/** SQL type literal, e.g. "varchar(255)" */
|
|
700
|
+
castType: string;
|
|
701
|
+
/** Optional alias for the result */
|
|
702
|
+
alias?: string;
|
|
703
|
+
}
|
|
692
704
|
/**
|
|
693
705
|
* AST node representing a window function
|
|
694
706
|
*/
|
|
@@ -717,12 +729,13 @@ interface ArithmeticExpressionNode {
|
|
|
717
729
|
/**
|
|
718
730
|
* Union type representing any operand that can be used in expressions
|
|
719
731
|
*/
|
|
720
|
-
type OperandNode = AliasRefNode | ColumnNode | LiteralNode | FunctionNode | JsonPathNode | ScalarSubqueryNode | CaseExpressionNode | WindowFunctionNode;
|
|
732
|
+
type OperandNode = AliasRefNode | ColumnNode | LiteralNode | FunctionNode | JsonPathNode | ScalarSubqueryNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode | ArithmeticExpressionNode;
|
|
721
733
|
declare const isOperandNode: (node: unknown) => node is OperandNode;
|
|
722
734
|
declare const isFunctionNode: (node: unknown) => node is FunctionNode;
|
|
723
735
|
declare const isCaseExpressionNode: (node: unknown) => node is CaseExpressionNode;
|
|
736
|
+
declare const isCastExpressionNode: (node: unknown) => node is CastExpressionNode;
|
|
724
737
|
declare const isWindowFunctionNode: (node: unknown) => node is WindowFunctionNode;
|
|
725
|
-
declare const isExpressionSelectionNode: (node: ColumnRef | FunctionNode | CaseExpressionNode | WindowFunctionNode) => node is FunctionNode | CaseExpressionNode | WindowFunctionNode;
|
|
738
|
+
declare const isExpressionSelectionNode: (node: ColumnRef | FunctionNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode) => node is FunctionNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode;
|
|
726
739
|
/**
|
|
727
740
|
* AST node representing a binary expression (e.g., column = value)
|
|
728
741
|
*/
|
|
@@ -956,6 +969,10 @@ declare const caseWhen: (conditions: {
|
|
|
956
969
|
when: ExpressionNode;
|
|
957
970
|
then: OperandNode | ColumnRef | string | number | boolean | null;
|
|
958
971
|
}[], elseValue?: OperandNode | ColumnRef | string | number | boolean | null) => CaseExpressionNode;
|
|
972
|
+
/**
|
|
973
|
+
* Builds a CAST expression node for casting values to SQL types.
|
|
974
|
+
*/
|
|
975
|
+
declare const cast: (expression: OperandNode | ColumnRef | string | number | boolean | null, castType: string) => CastExpressionNode;
|
|
959
976
|
/**
|
|
960
977
|
* Creates an EXISTS expression
|
|
961
978
|
* @param subquery - Subquery to check for existence
|
|
@@ -1097,6 +1114,7 @@ interface OperandVisitor<R> {
|
|
|
1097
1114
|
visitJsonPath?(node: JsonPathNode): R;
|
|
1098
1115
|
visitScalarSubquery?(node: ScalarSubqueryNode): R;
|
|
1099
1116
|
visitCaseExpression?(node: CaseExpressionNode): R;
|
|
1117
|
+
visitCast?(node: CastExpressionNode): R;
|
|
1100
1118
|
visitWindowFunction?(node: WindowFunctionNode): R;
|
|
1101
1119
|
visitAliasRef?(node: AliasRefNode): R;
|
|
1102
1120
|
otherwise?(node: OperandNode): R;
|
|
@@ -1256,7 +1274,7 @@ interface SelectQueryNode {
|
|
|
1256
1274
|
/** FROM clause table (either a Table or a FunctionTable) */
|
|
1257
1275
|
from: TableSourceNode;
|
|
1258
1276
|
/** SELECT clause columns */
|
|
1259
|
-
columns: (ColumnNode | FunctionNode | ScalarSubqueryNode | CaseExpressionNode | WindowFunctionNode)[];
|
|
1277
|
+
columns: (ColumnNode | FunctionNode | ScalarSubqueryNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode)[];
|
|
1260
1278
|
/** JOIN clauses */
|
|
1261
1279
|
joins: JoinNode[];
|
|
1262
1280
|
/** Optional WHERE clause */
|
|
@@ -1588,7 +1606,7 @@ type DialectKey = 'postgres' | 'mysql' | 'sqlite' | 'mssql' | (string & {});
|
|
|
1588
1606
|
/**
|
|
1589
1607
|
* Node types that can be used in query projections
|
|
1590
1608
|
*/
|
|
1591
|
-
type ProjectionNode = ColumnNode | FunctionNode | ScalarSubqueryNode | CaseExpressionNode | WindowFunctionNode;
|
|
1609
|
+
type ProjectionNode = ColumnNode | FunctionNode | ScalarSubqueryNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode;
|
|
1592
1610
|
/**
|
|
1593
1611
|
* Manages the state of a SELECT query being built
|
|
1594
1612
|
*/
|
|
@@ -1891,7 +1909,7 @@ declare class QueryAstService {
|
|
|
1891
1909
|
* @param columns - Columns to select (key: alias, value: column definition or expression)
|
|
1892
1910
|
* @returns Column selection result with updated state and added columns
|
|
1893
1911
|
*/
|
|
1894
|
-
select(columns: Record<string, ColumnDef | FunctionNode | CaseExpressionNode | WindowFunctionNode>): ColumnSelectionResult;
|
|
1912
|
+
select(columns: Record<string, ColumnDef | FunctionNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode>): ColumnSelectionResult;
|
|
1895
1913
|
/**
|
|
1896
1914
|
* Selects raw column expressions (best-effort parser for simple references/functions)
|
|
1897
1915
|
* @param cols - Raw column expressions
|
|
@@ -4164,6 +4182,7 @@ interface DatabaseColumn {
|
|
|
4164
4182
|
generated?: 'always' | 'byDefault';
|
|
4165
4183
|
unique?: boolean | string;
|
|
4166
4184
|
references?: ForeignKeyReference;
|
|
4185
|
+
comment?: string;
|
|
4167
4186
|
check?: string;
|
|
4168
4187
|
}
|
|
4169
4188
|
/** Represents an index in the database schema. */
|
|
@@ -4186,6 +4205,7 @@ interface DatabaseTable {
|
|
|
4186
4205
|
primaryKey?: string[];
|
|
4187
4206
|
indexes?: DatabaseIndex[];
|
|
4188
4207
|
checks?: DatabaseCheck[];
|
|
4208
|
+
comment?: string;
|
|
4189
4209
|
}
|
|
4190
4210
|
/** Represents the overall database schema. */
|
|
4191
4211
|
interface DatabaseSchema {
|
|
@@ -4913,6 +4933,7 @@ declare class TypeScriptGenerator implements ExpressionVisitor<string>, OperandV
|
|
|
4913
4933
|
visitScalarSubquery(node: ScalarSubqueryNode): string;
|
|
4914
4934
|
visitCaseExpression(node: CaseExpressionNode): string;
|
|
4915
4935
|
visitWindowFunction(node: WindowFunctionNode): string;
|
|
4936
|
+
visitCast(node: CastExpressionNode): string;
|
|
4916
4937
|
visitAliasRef(node: AliasRefNode): string;
|
|
4917
4938
|
/**
|
|
4918
4939
|
* Prints a binary expression to TypeScript code
|
|
@@ -4993,6 +5014,7 @@ declare class TypeScriptGenerator implements ExpressionVisitor<string>, OperandV
|
|
|
4993
5014
|
* @returns TypeScript code representation
|
|
4994
5015
|
*/
|
|
4995
5016
|
private printWindowFunctionOperand;
|
|
5017
|
+
private printCastOperand;
|
|
4996
5018
|
/**
|
|
4997
5019
|
* Converts method chain lines to inline format
|
|
4998
5020
|
* @param lines - Method chain lines
|
|
@@ -5527,4 +5549,4 @@ type PooledExecutorFactoryOptions<TConn> = {
|
|
|
5527
5549
|
*/
|
|
5528
5550
|
declare function createPooledExecutorFactory<TConn>(opts: PooledExecutorFactoryOptions<TConn>): DbExecutorFactory;
|
|
5529
5551
|
|
|
5530
|
-
export { type AliasRefNode, type AnyDomainEvent, type ArithmeticExpressionNode, type TableRef as AstTableRef, AsyncLocalStorage, BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToManyRelation, type BelongsToOptions, type BelongsToReference, type BelongsToRelation, type BetweenExpressionNode, type BinaryExpressionNode, type CascadeMode, type CaseExpressionNode, type CheckConstraint, Column, type ColumnDef, type ColumnDiff, type ColumnInput, type ColumnNode, type ColumnOptions, type ColumnRef, type ColumnToTs, type ColumnType, type CreateTediousClientOptions, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, type DbExecutor, type DbExecutorFactory, DefaultBelongsToReference, DefaultHasManyCollection, DefaultManyToManyCollection, type DefaultValue, DeleteQueryBuilder, type DialectName, type DomainEvent, DomainEventBus, type DomainEventHandler, Entity, type EntityContext, type EntityInstance, type EntityOptions, 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 HasOneRelation, type HydrationContext, type HydrationMetadata, type HydrationPivotPlan, type HydrationPlan, type HydrationRelationPlan, type InExpressionNode, type InExpressionRight, type IndexColumn, type IndexDef, type InferRow, type InitialHandlers, InsertQueryBuilder, type IntrospectOptions, type JsonPathNode, type LiteralNode, type LiteralValue, type LogicalExpressionNode, type ManyToManyCollection, type MssqlClientLike, MySqlDialect, type MysqlClientLike, type NullExpressionNode, type OperandNode, type OperandVisitor, Orm, type OrmDomainEvent, type OrmInterceptor, type OrmOptions, OrmSession, type OrmSessionOptions, Pool, type PoolAdapter, type PoolLease, type PoolOptions, type PooledConnectionAdapter, type PostgresClientLike, PostgresDialect, PrimaryKey, type QueryLogEntry, type QueryLogger, type QueryResult, type RawDefaultValue, type ReferentialAction, type RelationChange, type RelationChangeEntry, type RelationDef, type RelationKey, RelationKinds, type RelationMap, type RelationTargetTable, type RelationType, type RenderColumnOptions, STANDARD_COLUMN_TYPES, type ScalarSubqueryNode, type SchemaChange, type SchemaChangeKind, type SchemaDiffOptions, type SchemaGenerateResult, type SchemaIntrospector, type SchemaPlan, SelectQueryBuilder, type SelectQueryInput, 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, UpdateQueryBuilder, type ValueOperandInput, type WindowFunctionNode, abs, acos, add, addDomainEvent, aliasRef, and, ascii, asin, atan, atan2, avg, belongsTo, belongsToMany, between, bootstrapEntities, caseWhen, ceil, ceiling, char, charLength, clearExpressionDispatchers, clearOperandDispatchers, col, columnOperand, concat, concatWs, correlateBy, cos, cot, count, createEntityFromRow, createEntityProxy, createExecutorFromQueryRunner, createMssqlExecutor, createMysqlExecutor, createPooledExecutorFactory, createPostgresExecutor, createQueryLoggingExecutor, createSqliteExecutor, createTediousExecutor, createTediousMssqlClient, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, defineTable, degrees, denseRank, diffSchema, div, endOfMonth, entityRef, eq, esel, executeHydrated, executeHydratedWithContexts, exists, exp, extract, firstValue, floor, fromUnixTime, generateCreateTableSql, generateSchemaSql, getColumn, getSchemaIntrospector, getTableDefFromEntity, groupConcat, gt, gte, hasMany, hasOne, hydrateRows, inList, inSubquery, instr, introspectSchema, isCaseExpressionNode, isExpressionSelectionNode, isFunctionNode, isNotNull, isNull, isOperandNode, isValueOperandInput, isWindowFunctionNode, jsonPath, lag, lastValue, lead, left, length, like, ln, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, loadHasOneRelation, locate, log, log10, logBase, lower, lpad, lt, lte, ltrim, max, min, mod, month, mul, neq, normalizeColumnType, notBetween, notExists, notInList, notInSubquery, notLike, now, ntile, or, outerRef, pi, position, pow, power, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, renderColumnDefinition, renderTypeWithArgs, repeat, replace, right, round, rowNumber, rowsToQueryResult, rpad, rtrim, sel, selectFromEntity, sign, sin, space, sqrt, sub, substr, sum, synchronizeSchema, tableRef, tan, toColumnRef, toTableRef, trim, trunc, truncate, unixTimestamp, upper, utcNow, valueToOperand, visitExpression, visitOperand, weekOfYear, windowFunction, year };
|
|
5552
|
+
export { type AliasRefNode, type AnyDomainEvent, type ArithmeticExpressionNode, type TableRef as AstTableRef, AsyncLocalStorage, BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToManyRelation, type BelongsToOptions, type BelongsToReference, type BelongsToRelation, type BetweenExpressionNode, type BinaryExpressionNode, type CascadeMode, type CaseExpressionNode, type CastExpressionNode, type CheckConstraint, Column, type ColumnDef, type ColumnDiff, type ColumnInput, type ColumnNode, type ColumnOptions, type ColumnRef, type ColumnToTs, type ColumnType, type CreateTediousClientOptions, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, type DbExecutor, type DbExecutorFactory, DefaultBelongsToReference, DefaultHasManyCollection, DefaultManyToManyCollection, type DefaultValue, DeleteQueryBuilder, type DialectName, type DomainEvent, DomainEventBus, type DomainEventHandler, Entity, type EntityContext, type EntityInstance, type EntityOptions, 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 HasOneRelation, type HydrationContext, type HydrationMetadata, type HydrationPivotPlan, type HydrationPlan, type HydrationRelationPlan, type InExpressionNode, type InExpressionRight, type IndexColumn, type IndexDef, type InferRow, type InitialHandlers, InsertQueryBuilder, type IntrospectOptions, type JsonPathNode, type LiteralNode, type LiteralValue, type LogicalExpressionNode, type ManyToManyCollection, type MssqlClientLike, MySqlDialect, type MysqlClientLike, type NullExpressionNode, type OperandNode, type OperandVisitor, Orm, type OrmDomainEvent, type OrmInterceptor, type OrmOptions, OrmSession, type OrmSessionOptions, Pool, type PoolAdapter, type PoolLease, type PoolOptions, type PooledConnectionAdapter, type PostgresClientLike, PostgresDialect, PrimaryKey, type QueryLogEntry, type QueryLogger, type QueryResult, type RawDefaultValue, type ReferentialAction, type RelationChange, type RelationChangeEntry, type RelationDef, type RelationKey, RelationKinds, type RelationMap, type RelationTargetTable, type RelationType, type RenderColumnOptions, STANDARD_COLUMN_TYPES, type ScalarSubqueryNode, type SchemaChange, type SchemaChangeKind, type SchemaDiffOptions, type SchemaGenerateResult, type SchemaIntrospector, type SchemaPlan, SelectQueryBuilder, type SelectQueryInput, 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, UpdateQueryBuilder, type ValueOperandInput, type WindowFunctionNode, abs, acos, add, addDomainEvent, aliasRef, and, ascii, asin, atan, atan2, avg, belongsTo, belongsToMany, between, bootstrapEntities, caseWhen, cast, ceil, ceiling, char, charLength, clearExpressionDispatchers, clearOperandDispatchers, col, columnOperand, concat, concatWs, correlateBy, cos, cot, count, createEntityFromRow, createEntityProxy, createExecutorFromQueryRunner, createMssqlExecutor, createMysqlExecutor, createPooledExecutorFactory, createPostgresExecutor, createQueryLoggingExecutor, createSqliteExecutor, createTediousExecutor, createTediousMssqlClient, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, defineTable, degrees, denseRank, diffSchema, div, endOfMonth, entityRef, eq, esel, executeHydrated, executeHydratedWithContexts, exists, exp, extract, firstValue, floor, fromUnixTime, generateCreateTableSql, generateSchemaSql, getColumn, getSchemaIntrospector, getTableDefFromEntity, groupConcat, gt, gte, hasMany, hasOne, hydrateRows, inList, inSubquery, instr, introspectSchema, isCaseExpressionNode, isCastExpressionNode, isExpressionSelectionNode, isFunctionNode, isNotNull, isNull, isOperandNode, isValueOperandInput, isWindowFunctionNode, jsonPath, lag, lastValue, lead, left, length, like, ln, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, loadHasOneRelation, locate, log, log10, logBase, lower, lpad, lt, lte, ltrim, max, min, mod, month, mul, neq, normalizeColumnType, notBetween, notExists, notInList, notInSubquery, notLike, now, ntile, or, outerRef, pi, position, pow, power, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, renderColumnDefinition, renderTypeWithArgs, repeat, replace, right, round, rowNumber, rowsToQueryResult, rpad, rtrim, sel, selectFromEntity, sign, sin, space, sqrt, sub, substr, sum, synchronizeSchema, tableRef, tan, toColumnRef, toTableRef, trim, trunc, truncate, unixTimestamp, upper, utcNow, valueToOperand, visitExpression, visitOperand, weekOfYear, windowFunction, year };
|
package/dist/index.d.ts
CHANGED
|
@@ -689,6 +689,18 @@ interface CaseExpressionNode {
|
|
|
689
689
|
/** Optional alias for the result */
|
|
690
690
|
alias?: string;
|
|
691
691
|
}
|
|
692
|
+
/**
|
|
693
|
+
* AST node representing a CAST expression (CAST(value AS type)).
|
|
694
|
+
*/
|
|
695
|
+
interface CastExpressionNode {
|
|
696
|
+
type: 'Cast';
|
|
697
|
+
/** Expression being cast */
|
|
698
|
+
expression: OperandNode;
|
|
699
|
+
/** SQL type literal, e.g. "varchar(255)" */
|
|
700
|
+
castType: string;
|
|
701
|
+
/** Optional alias for the result */
|
|
702
|
+
alias?: string;
|
|
703
|
+
}
|
|
692
704
|
/**
|
|
693
705
|
* AST node representing a window function
|
|
694
706
|
*/
|
|
@@ -717,12 +729,13 @@ interface ArithmeticExpressionNode {
|
|
|
717
729
|
/**
|
|
718
730
|
* Union type representing any operand that can be used in expressions
|
|
719
731
|
*/
|
|
720
|
-
type OperandNode = AliasRefNode | ColumnNode | LiteralNode | FunctionNode | JsonPathNode | ScalarSubqueryNode | CaseExpressionNode | WindowFunctionNode;
|
|
732
|
+
type OperandNode = AliasRefNode | ColumnNode | LiteralNode | FunctionNode | JsonPathNode | ScalarSubqueryNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode | ArithmeticExpressionNode;
|
|
721
733
|
declare const isOperandNode: (node: unknown) => node is OperandNode;
|
|
722
734
|
declare const isFunctionNode: (node: unknown) => node is FunctionNode;
|
|
723
735
|
declare const isCaseExpressionNode: (node: unknown) => node is CaseExpressionNode;
|
|
736
|
+
declare const isCastExpressionNode: (node: unknown) => node is CastExpressionNode;
|
|
724
737
|
declare const isWindowFunctionNode: (node: unknown) => node is WindowFunctionNode;
|
|
725
|
-
declare const isExpressionSelectionNode: (node: ColumnRef | FunctionNode | CaseExpressionNode | WindowFunctionNode) => node is FunctionNode | CaseExpressionNode | WindowFunctionNode;
|
|
738
|
+
declare const isExpressionSelectionNode: (node: ColumnRef | FunctionNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode) => node is FunctionNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode;
|
|
726
739
|
/**
|
|
727
740
|
* AST node representing a binary expression (e.g., column = value)
|
|
728
741
|
*/
|
|
@@ -956,6 +969,10 @@ declare const caseWhen: (conditions: {
|
|
|
956
969
|
when: ExpressionNode;
|
|
957
970
|
then: OperandNode | ColumnRef | string | number | boolean | null;
|
|
958
971
|
}[], elseValue?: OperandNode | ColumnRef | string | number | boolean | null) => CaseExpressionNode;
|
|
972
|
+
/**
|
|
973
|
+
* Builds a CAST expression node for casting values to SQL types.
|
|
974
|
+
*/
|
|
975
|
+
declare const cast: (expression: OperandNode | ColumnRef | string | number | boolean | null, castType: string) => CastExpressionNode;
|
|
959
976
|
/**
|
|
960
977
|
* Creates an EXISTS expression
|
|
961
978
|
* @param subquery - Subquery to check for existence
|
|
@@ -1097,6 +1114,7 @@ interface OperandVisitor<R> {
|
|
|
1097
1114
|
visitJsonPath?(node: JsonPathNode): R;
|
|
1098
1115
|
visitScalarSubquery?(node: ScalarSubqueryNode): R;
|
|
1099
1116
|
visitCaseExpression?(node: CaseExpressionNode): R;
|
|
1117
|
+
visitCast?(node: CastExpressionNode): R;
|
|
1100
1118
|
visitWindowFunction?(node: WindowFunctionNode): R;
|
|
1101
1119
|
visitAliasRef?(node: AliasRefNode): R;
|
|
1102
1120
|
otherwise?(node: OperandNode): R;
|
|
@@ -1256,7 +1274,7 @@ interface SelectQueryNode {
|
|
|
1256
1274
|
/** FROM clause table (either a Table or a FunctionTable) */
|
|
1257
1275
|
from: TableSourceNode;
|
|
1258
1276
|
/** SELECT clause columns */
|
|
1259
|
-
columns: (ColumnNode | FunctionNode | ScalarSubqueryNode | CaseExpressionNode | WindowFunctionNode)[];
|
|
1277
|
+
columns: (ColumnNode | FunctionNode | ScalarSubqueryNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode)[];
|
|
1260
1278
|
/** JOIN clauses */
|
|
1261
1279
|
joins: JoinNode[];
|
|
1262
1280
|
/** Optional WHERE clause */
|
|
@@ -1588,7 +1606,7 @@ type DialectKey = 'postgres' | 'mysql' | 'sqlite' | 'mssql' | (string & {});
|
|
|
1588
1606
|
/**
|
|
1589
1607
|
* Node types that can be used in query projections
|
|
1590
1608
|
*/
|
|
1591
|
-
type ProjectionNode = ColumnNode | FunctionNode | ScalarSubqueryNode | CaseExpressionNode | WindowFunctionNode;
|
|
1609
|
+
type ProjectionNode = ColumnNode | FunctionNode | ScalarSubqueryNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode;
|
|
1592
1610
|
/**
|
|
1593
1611
|
* Manages the state of a SELECT query being built
|
|
1594
1612
|
*/
|
|
@@ -1891,7 +1909,7 @@ declare class QueryAstService {
|
|
|
1891
1909
|
* @param columns - Columns to select (key: alias, value: column definition or expression)
|
|
1892
1910
|
* @returns Column selection result with updated state and added columns
|
|
1893
1911
|
*/
|
|
1894
|
-
select(columns: Record<string, ColumnDef | FunctionNode | CaseExpressionNode | WindowFunctionNode>): ColumnSelectionResult;
|
|
1912
|
+
select(columns: Record<string, ColumnDef | FunctionNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode>): ColumnSelectionResult;
|
|
1895
1913
|
/**
|
|
1896
1914
|
* Selects raw column expressions (best-effort parser for simple references/functions)
|
|
1897
1915
|
* @param cols - Raw column expressions
|
|
@@ -4164,6 +4182,7 @@ interface DatabaseColumn {
|
|
|
4164
4182
|
generated?: 'always' | 'byDefault';
|
|
4165
4183
|
unique?: boolean | string;
|
|
4166
4184
|
references?: ForeignKeyReference;
|
|
4185
|
+
comment?: string;
|
|
4167
4186
|
check?: string;
|
|
4168
4187
|
}
|
|
4169
4188
|
/** Represents an index in the database schema. */
|
|
@@ -4186,6 +4205,7 @@ interface DatabaseTable {
|
|
|
4186
4205
|
primaryKey?: string[];
|
|
4187
4206
|
indexes?: DatabaseIndex[];
|
|
4188
4207
|
checks?: DatabaseCheck[];
|
|
4208
|
+
comment?: string;
|
|
4189
4209
|
}
|
|
4190
4210
|
/** Represents the overall database schema. */
|
|
4191
4211
|
interface DatabaseSchema {
|
|
@@ -4913,6 +4933,7 @@ declare class TypeScriptGenerator implements ExpressionVisitor<string>, OperandV
|
|
|
4913
4933
|
visitScalarSubquery(node: ScalarSubqueryNode): string;
|
|
4914
4934
|
visitCaseExpression(node: CaseExpressionNode): string;
|
|
4915
4935
|
visitWindowFunction(node: WindowFunctionNode): string;
|
|
4936
|
+
visitCast(node: CastExpressionNode): string;
|
|
4916
4937
|
visitAliasRef(node: AliasRefNode): string;
|
|
4917
4938
|
/**
|
|
4918
4939
|
* Prints a binary expression to TypeScript code
|
|
@@ -4993,6 +5014,7 @@ declare class TypeScriptGenerator implements ExpressionVisitor<string>, OperandV
|
|
|
4993
5014
|
* @returns TypeScript code representation
|
|
4994
5015
|
*/
|
|
4995
5016
|
private printWindowFunctionOperand;
|
|
5017
|
+
private printCastOperand;
|
|
4996
5018
|
/**
|
|
4997
5019
|
* Converts method chain lines to inline format
|
|
4998
5020
|
* @param lines - Method chain lines
|
|
@@ -5527,4 +5549,4 @@ type PooledExecutorFactoryOptions<TConn> = {
|
|
|
5527
5549
|
*/
|
|
5528
5550
|
declare function createPooledExecutorFactory<TConn>(opts: PooledExecutorFactoryOptions<TConn>): DbExecutorFactory;
|
|
5529
5551
|
|
|
5530
|
-
export { type AliasRefNode, type AnyDomainEvent, type ArithmeticExpressionNode, type TableRef as AstTableRef, AsyncLocalStorage, BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToManyRelation, type BelongsToOptions, type BelongsToReference, type BelongsToRelation, type BetweenExpressionNode, type BinaryExpressionNode, type CascadeMode, type CaseExpressionNode, type CheckConstraint, Column, type ColumnDef, type ColumnDiff, type ColumnInput, type ColumnNode, type ColumnOptions, type ColumnRef, type ColumnToTs, type ColumnType, type CreateTediousClientOptions, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, type DbExecutor, type DbExecutorFactory, DefaultBelongsToReference, DefaultHasManyCollection, DefaultManyToManyCollection, type DefaultValue, DeleteQueryBuilder, type DialectName, type DomainEvent, DomainEventBus, type DomainEventHandler, Entity, type EntityContext, type EntityInstance, type EntityOptions, 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 HasOneRelation, type HydrationContext, type HydrationMetadata, type HydrationPivotPlan, type HydrationPlan, type HydrationRelationPlan, type InExpressionNode, type InExpressionRight, type IndexColumn, type IndexDef, type InferRow, type InitialHandlers, InsertQueryBuilder, type IntrospectOptions, type JsonPathNode, type LiteralNode, type LiteralValue, type LogicalExpressionNode, type ManyToManyCollection, type MssqlClientLike, MySqlDialect, type MysqlClientLike, type NullExpressionNode, type OperandNode, type OperandVisitor, Orm, type OrmDomainEvent, type OrmInterceptor, type OrmOptions, OrmSession, type OrmSessionOptions, Pool, type PoolAdapter, type PoolLease, type PoolOptions, type PooledConnectionAdapter, type PostgresClientLike, PostgresDialect, PrimaryKey, type QueryLogEntry, type QueryLogger, type QueryResult, type RawDefaultValue, type ReferentialAction, type RelationChange, type RelationChangeEntry, type RelationDef, type RelationKey, RelationKinds, type RelationMap, type RelationTargetTable, type RelationType, type RenderColumnOptions, STANDARD_COLUMN_TYPES, type ScalarSubqueryNode, type SchemaChange, type SchemaChangeKind, type SchemaDiffOptions, type SchemaGenerateResult, type SchemaIntrospector, type SchemaPlan, SelectQueryBuilder, type SelectQueryInput, 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, UpdateQueryBuilder, type ValueOperandInput, type WindowFunctionNode, abs, acos, add, addDomainEvent, aliasRef, and, ascii, asin, atan, atan2, avg, belongsTo, belongsToMany, between, bootstrapEntities, caseWhen, ceil, ceiling, char, charLength, clearExpressionDispatchers, clearOperandDispatchers, col, columnOperand, concat, concatWs, correlateBy, cos, cot, count, createEntityFromRow, createEntityProxy, createExecutorFromQueryRunner, createMssqlExecutor, createMysqlExecutor, createPooledExecutorFactory, createPostgresExecutor, createQueryLoggingExecutor, createSqliteExecutor, createTediousExecutor, createTediousMssqlClient, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, defineTable, degrees, denseRank, diffSchema, div, endOfMonth, entityRef, eq, esel, executeHydrated, executeHydratedWithContexts, exists, exp, extract, firstValue, floor, fromUnixTime, generateCreateTableSql, generateSchemaSql, getColumn, getSchemaIntrospector, getTableDefFromEntity, groupConcat, gt, gte, hasMany, hasOne, hydrateRows, inList, inSubquery, instr, introspectSchema, isCaseExpressionNode, isExpressionSelectionNode, isFunctionNode, isNotNull, isNull, isOperandNode, isValueOperandInput, isWindowFunctionNode, jsonPath, lag, lastValue, lead, left, length, like, ln, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, loadHasOneRelation, locate, log, log10, logBase, lower, lpad, lt, lte, ltrim, max, min, mod, month, mul, neq, normalizeColumnType, notBetween, notExists, notInList, notInSubquery, notLike, now, ntile, or, outerRef, pi, position, pow, power, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, renderColumnDefinition, renderTypeWithArgs, repeat, replace, right, round, rowNumber, rowsToQueryResult, rpad, rtrim, sel, selectFromEntity, sign, sin, space, sqrt, sub, substr, sum, synchronizeSchema, tableRef, tan, toColumnRef, toTableRef, trim, trunc, truncate, unixTimestamp, upper, utcNow, valueToOperand, visitExpression, visitOperand, weekOfYear, windowFunction, year };
|
|
5552
|
+
export { type AliasRefNode, type AnyDomainEvent, type ArithmeticExpressionNode, type TableRef as AstTableRef, AsyncLocalStorage, BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToManyRelation, type BelongsToOptions, type BelongsToReference, type BelongsToRelation, type BetweenExpressionNode, type BinaryExpressionNode, type CascadeMode, type CaseExpressionNode, type CastExpressionNode, type CheckConstraint, Column, type ColumnDef, type ColumnDiff, type ColumnInput, type ColumnNode, type ColumnOptions, type ColumnRef, type ColumnToTs, type ColumnType, type CreateTediousClientOptions, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, type DbExecutor, type DbExecutorFactory, DefaultBelongsToReference, DefaultHasManyCollection, DefaultManyToManyCollection, type DefaultValue, DeleteQueryBuilder, type DialectName, type DomainEvent, DomainEventBus, type DomainEventHandler, Entity, type EntityContext, type EntityInstance, type EntityOptions, 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 HasOneRelation, type HydrationContext, type HydrationMetadata, type HydrationPivotPlan, type HydrationPlan, type HydrationRelationPlan, type InExpressionNode, type InExpressionRight, type IndexColumn, type IndexDef, type InferRow, type InitialHandlers, InsertQueryBuilder, type IntrospectOptions, type JsonPathNode, type LiteralNode, type LiteralValue, type LogicalExpressionNode, type ManyToManyCollection, type MssqlClientLike, MySqlDialect, type MysqlClientLike, type NullExpressionNode, type OperandNode, type OperandVisitor, Orm, type OrmDomainEvent, type OrmInterceptor, type OrmOptions, OrmSession, type OrmSessionOptions, Pool, type PoolAdapter, type PoolLease, type PoolOptions, type PooledConnectionAdapter, type PostgresClientLike, PostgresDialect, PrimaryKey, type QueryLogEntry, type QueryLogger, type QueryResult, type RawDefaultValue, type ReferentialAction, type RelationChange, type RelationChangeEntry, type RelationDef, type RelationKey, RelationKinds, type RelationMap, type RelationTargetTable, type RelationType, type RenderColumnOptions, STANDARD_COLUMN_TYPES, type ScalarSubqueryNode, type SchemaChange, type SchemaChangeKind, type SchemaDiffOptions, type SchemaGenerateResult, type SchemaIntrospector, type SchemaPlan, SelectQueryBuilder, type SelectQueryInput, 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, UpdateQueryBuilder, type ValueOperandInput, type WindowFunctionNode, abs, acos, add, addDomainEvent, aliasRef, and, ascii, asin, atan, atan2, avg, belongsTo, belongsToMany, between, bootstrapEntities, caseWhen, cast, ceil, ceiling, char, charLength, clearExpressionDispatchers, clearOperandDispatchers, col, columnOperand, concat, concatWs, correlateBy, cos, cot, count, createEntityFromRow, createEntityProxy, createExecutorFromQueryRunner, createMssqlExecutor, createMysqlExecutor, createPooledExecutorFactory, createPostgresExecutor, createQueryLoggingExecutor, createSqliteExecutor, createTediousExecutor, createTediousMssqlClient, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, defineTable, degrees, denseRank, diffSchema, div, endOfMonth, entityRef, eq, esel, executeHydrated, executeHydratedWithContexts, exists, exp, extract, firstValue, floor, fromUnixTime, generateCreateTableSql, generateSchemaSql, getColumn, getSchemaIntrospector, getTableDefFromEntity, groupConcat, gt, gte, hasMany, hasOne, hydrateRows, inList, inSubquery, instr, introspectSchema, isCaseExpressionNode, isCastExpressionNode, isExpressionSelectionNode, isFunctionNode, isNotNull, isNull, isOperandNode, isValueOperandInput, isWindowFunctionNode, jsonPath, lag, lastValue, lead, left, length, like, ln, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, loadHasOneRelation, locate, log, log10, logBase, lower, lpad, lt, lte, ltrim, max, min, mod, month, mul, neq, normalizeColumnType, notBetween, notExists, notInList, notInSubquery, notLike, now, ntile, or, outerRef, pi, position, pow, power, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, renderColumnDefinition, renderTypeWithArgs, repeat, replace, right, round, rowNumber, rowsToQueryResult, rpad, rtrim, sel, selectFromEntity, sign, sin, space, sqrt, sub, substr, sum, synchronizeSchema, tableRef, tan, toColumnRef, toTableRef, trim, trunc, truncate, unixTimestamp, upper, utcNow, valueToOperand, visitExpression, visitOperand, weekOfYear, windowFunction, year };
|