metal-orm 1.0.12 → 1.0.14

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
@@ -1,5 +1,5 @@
1
- import { O as OperandNode, C as ColumnDef, a as ColumnNode, B as BinaryExpressionNode, E as ExpressionNode, L as LogicalExpressionNode, N as NullExpressionNode, b as LiteralNode, I as InExpressionNode, c as BetweenExpressionNode, J as JsonPathNode, d as CaseExpressionNode, S as SelectQueryNode, e as ExistsExpressionNode, W as WindowFunctionNode, f as OrderDirection, F as FunctionNode, g as ScalarSubqueryNode, T as TableDef, h as InsertQueryNode, i as InsertCompiler, j as CompiledQuery, U as UpdateQueryNode, k as UpdateCompiler, D as DeleteQueryNode, l as DeleteCompiler, m as Dialect, n as CompilerContext, o as ForeignKeyReference, p as IndexColumn, q as IndexDef, r as DbExecutor, H as HydrationPlan, R as RelationMap, s as OrmContext, t as Entity, u as HasManyRelation, v as BelongsToRelation, w as BelongsToManyRelation, x as HasManyCollection, y as BelongsToReference, M as ManyToManyCollection, z as SelectQueryBuilder } from './select-BKlr2ivY.cjs';
2
- export { a0 as CascadeMode, A as CheckConstraint, a5 as ColumnToTs, Q as ColumnType, Y as DefaultValue, al as DomainEventHandler, af as EntityStatus, aj as HasDomainEvents, a6 as InferRow, am as OrmContextOptions, ak as OrmInterceptor, ag as QueryResult, X as RawDefaultValue, V as ReferentialAction, ai as RelationChange, a1 as RelationDef, ah as RelationKey, _ as RelationKinds, $ as RelationType, K as TableHooks, G as TableOptions, ae as addDomainEvent, a3 as belongsTo, a4 as belongsToMany, Z as col, a7 as createColumn, a8 as createLiteral, P as defineTable, a2 as hasMany, ab as isCaseExpressionNode, ad as isExpressionSelectionNode, aa as isFunctionNode, a9 as isOperandNode, ac as isWindowFunctionNode } from './select-BKlr2ivY.cjs';
1
+ import { O as OperandNode, C as ColumnDef, a as ColumnNode, B as BinaryExpressionNode, E as ExpressionNode, L as LogicalExpressionNode, N as NullExpressionNode, b as LiteralNode, I as InExpressionNode, c as BetweenExpressionNode, J as JsonPathNode, d as CaseExpressionNode, S as SelectQueryNode, e as ExistsExpressionNode, W as WindowFunctionNode, f as OrderDirection, F as FunctionNode, g as ScalarSubqueryNode, T as TableDef, h as InsertQueryNode, i as InsertCompiler, j as CompiledQuery, U as UpdateQueryNode, k as UpdateCompiler, D as DeleteQueryNode, l as DeleteCompiler, m as Dialect, n as CompilerContext, o as ForeignKeyReference, p as IndexColumn, q as IndexDef, r as DbExecutor, H as HydrationPlan, R as RelationMap, s as OrmContext, t as Entity, u as HasManyRelation, v as BelongsToRelation, w as BelongsToManyRelation, x as HasManyCollection, y as BelongsToReference, M as ManyToManyCollection, z as SelectQueryBuilder } from './select-CCp1oz9p.cjs';
2
+ export { a0 as CascadeMode, A as CheckConstraint, a5 as ColumnToTs, Q as ColumnType, Y as DefaultValue, al as DomainEventHandler, af as EntityStatus, aj as HasDomainEvents, a6 as InferRow, am as OrmContextOptions, ak as OrmInterceptor, an as QueryLogEntry, ao as QueryLogger, ag as QueryResult, X as RawDefaultValue, V as ReferentialAction, ai as RelationChange, a1 as RelationDef, ah as RelationKey, _ as RelationKinds, $ as RelationType, K as TableHooks, G as TableOptions, ae as addDomainEvent, a3 as belongsTo, a4 as belongsToMany, Z as col, a7 as createColumn, a8 as createLiteral, P as defineTable, a2 as hasMany, ab as isCaseExpressionNode, ad as isExpressionSelectionNode, aa as isFunctionNode, a9 as isOperandNode, ac as isWindowFunctionNode } from './select-CCp1oz9p.cjs';
3
3
 
4
4
  /**
5
5
  * Converts a primitive or existing operand into an operand node
@@ -357,12 +357,17 @@ declare abstract class SqlDialectBase extends Dialect {
357
357
  */
358
358
  protected compileSelectAst(ast: SelectQueryNode, ctx: CompilerContext): string;
359
359
  protected compileInsertAst(ast: InsertQueryNode, ctx: CompilerContext): string;
360
+ /**
361
+ * Compiles a single SELECT (no set operations, no CTE prefix).
362
+ */
363
+ private compileSelectCore;
360
364
  protected compileUpdateAst(ast: UpdateQueryNode, ctx: CompilerContext): string;
361
365
  protected compileDeleteAst(ast: DeleteQueryNode, ctx: CompilerContext): string;
362
366
  /**
363
367
  * Default RETURNING compilation: no support.
364
368
  */
365
369
  protected compileReturning(returning: ColumnNode[] | undefined, _ctx: CompilerContext): string;
370
+ protected formatReturningColumns(returning: ColumnNode[]): string;
366
371
  /**
367
372
  * DISTINCT clause. Override for DISTINCT ON support.
368
373
  */
@@ -383,6 +388,7 @@ declare abstract class SqlDialectBase extends Dialect {
383
388
  protected compilePagination(ast: SelectQueryNode, _orderByClause: string): string;
384
389
  protected compileCtes(ast: SelectQueryNode, ctx: CompilerContext): string;
385
390
  protected stripTrailingSemicolon(sql: string): string;
391
+ protected wrapSetOperand(sql: string): string;
386
392
  }
387
393
 
388
394
  /**
@@ -443,6 +449,11 @@ declare class SqlServerDialect extends Dialect {
443
449
  protected compileInsertAst(ast: InsertQueryNode, ctx: CompilerContext): string;
444
450
  protected compileUpdateAst(ast: UpdateQueryNode, ctx: CompilerContext): string;
445
451
  protected compileDeleteAst(ast: DeleteQueryNode, ctx: CompilerContext): string;
452
+ private compileSelectCore;
453
+ private compileOrderBy;
454
+ private compilePagination;
455
+ private compileCtes;
456
+ private wrapSetOperand;
446
457
  }
447
458
 
448
459
  /**
@@ -466,6 +477,7 @@ declare class SqliteDialect extends SqlDialectBase {
466
477
  */
467
478
  protected compileJsonPath(node: JsonPathNode): string;
468
479
  protected compileReturning(returning: ColumnNode[] | undefined, ctx: CompilerContext): string;
480
+ supportsReturning(): boolean;
469
481
  }
470
482
 
471
483
  /**
@@ -489,6 +501,7 @@ declare class PostgresDialect extends SqlDialectBase {
489
501
  */
490
502
  protected compileJsonPath(node: JsonPathNode): string;
491
503
  protected compileReturning(returning: ColumnNode[] | undefined, ctx: CompilerContext): string;
504
+ supportsReturning(): boolean;
492
505
  }
493
506
 
494
507
  interface DatabaseColumn {
@@ -881,6 +894,7 @@ declare class DefaultHasManyCollection<TChild> implements HasManyCollection<TChi
881
894
  clear(): void;
882
895
  private get relationKey();
883
896
  private hydrateFromCache;
897
+ toJSON(): TChild[];
884
898
  }
885
899
 
886
900
  type Rows$1 = Record<string, any>;
@@ -902,6 +916,7 @@ declare class DefaultBelongsToReference<TParent> implements BelongsToReference<T
902
916
  set(data: Partial<TParent> | TParent | null): TParent | null;
903
917
  private get relationKey();
904
918
  private populateFromHydrationCache;
919
+ toJSON(): TParent | null;
905
920
  }
906
921
 
907
922
  type Rows = Record<string, any>[];
@@ -928,6 +943,7 @@ declare class DefaultManyToManyCollection<TTarget> implements ManyToManyCollecti
928
943
  private get relationKey();
929
944
  private get targetKey();
930
945
  private hydrateFromCache;
946
+ toJSON(): TTarget[];
931
947
  }
932
948
 
933
949
  declare function executeHydrated<TTable extends TableDef>(ctx: OrmContext, qb: SelectQueryBuilder<any, TTable>): Promise<Entity<TTable>[]>;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { O as OperandNode, C as ColumnDef, a as ColumnNode, B as BinaryExpressionNode, E as ExpressionNode, L as LogicalExpressionNode, N as NullExpressionNode, b as LiteralNode, I as InExpressionNode, c as BetweenExpressionNode, J as JsonPathNode, d as CaseExpressionNode, S as SelectQueryNode, e as ExistsExpressionNode, W as WindowFunctionNode, f as OrderDirection, F as FunctionNode, g as ScalarSubqueryNode, T as TableDef, h as InsertQueryNode, i as InsertCompiler, j as CompiledQuery, U as UpdateQueryNode, k as UpdateCompiler, D as DeleteQueryNode, l as DeleteCompiler, m as Dialect, n as CompilerContext, o as ForeignKeyReference, p as IndexColumn, q as IndexDef, r as DbExecutor, H as HydrationPlan, R as RelationMap, s as OrmContext, t as Entity, u as HasManyRelation, v as BelongsToRelation, w as BelongsToManyRelation, x as HasManyCollection, y as BelongsToReference, M as ManyToManyCollection, z as SelectQueryBuilder } from './select-BKlr2ivY.js';
2
- export { a0 as CascadeMode, A as CheckConstraint, a5 as ColumnToTs, Q as ColumnType, Y as DefaultValue, al as DomainEventHandler, af as EntityStatus, aj as HasDomainEvents, a6 as InferRow, am as OrmContextOptions, ak as OrmInterceptor, ag as QueryResult, X as RawDefaultValue, V as ReferentialAction, ai as RelationChange, a1 as RelationDef, ah as RelationKey, _ as RelationKinds, $ as RelationType, K as TableHooks, G as TableOptions, ae as addDomainEvent, a3 as belongsTo, a4 as belongsToMany, Z as col, a7 as createColumn, a8 as createLiteral, P as defineTable, a2 as hasMany, ab as isCaseExpressionNode, ad as isExpressionSelectionNode, aa as isFunctionNode, a9 as isOperandNode, ac as isWindowFunctionNode } from './select-BKlr2ivY.js';
1
+ import { O as OperandNode, C as ColumnDef, a as ColumnNode, B as BinaryExpressionNode, E as ExpressionNode, L as LogicalExpressionNode, N as NullExpressionNode, b as LiteralNode, I as InExpressionNode, c as BetweenExpressionNode, J as JsonPathNode, d as CaseExpressionNode, S as SelectQueryNode, e as ExistsExpressionNode, W as WindowFunctionNode, f as OrderDirection, F as FunctionNode, g as ScalarSubqueryNode, T as TableDef, h as InsertQueryNode, i as InsertCompiler, j as CompiledQuery, U as UpdateQueryNode, k as UpdateCompiler, D as DeleteQueryNode, l as DeleteCompiler, m as Dialect, n as CompilerContext, o as ForeignKeyReference, p as IndexColumn, q as IndexDef, r as DbExecutor, H as HydrationPlan, R as RelationMap, s as OrmContext, t as Entity, u as HasManyRelation, v as BelongsToRelation, w as BelongsToManyRelation, x as HasManyCollection, y as BelongsToReference, M as ManyToManyCollection, z as SelectQueryBuilder } from './select-CCp1oz9p.js';
2
+ export { a0 as CascadeMode, A as CheckConstraint, a5 as ColumnToTs, Q as ColumnType, Y as DefaultValue, al as DomainEventHandler, af as EntityStatus, aj as HasDomainEvents, a6 as InferRow, am as OrmContextOptions, ak as OrmInterceptor, an as QueryLogEntry, ao as QueryLogger, ag as QueryResult, X as RawDefaultValue, V as ReferentialAction, ai as RelationChange, a1 as RelationDef, ah as RelationKey, _ as RelationKinds, $ as RelationType, K as TableHooks, G as TableOptions, ae as addDomainEvent, a3 as belongsTo, a4 as belongsToMany, Z as col, a7 as createColumn, a8 as createLiteral, P as defineTable, a2 as hasMany, ab as isCaseExpressionNode, ad as isExpressionSelectionNode, aa as isFunctionNode, a9 as isOperandNode, ac as isWindowFunctionNode } from './select-CCp1oz9p.js';
3
3
 
4
4
  /**
5
5
  * Converts a primitive or existing operand into an operand node
@@ -357,12 +357,17 @@ declare abstract class SqlDialectBase extends Dialect {
357
357
  */
358
358
  protected compileSelectAst(ast: SelectQueryNode, ctx: CompilerContext): string;
359
359
  protected compileInsertAst(ast: InsertQueryNode, ctx: CompilerContext): string;
360
+ /**
361
+ * Compiles a single SELECT (no set operations, no CTE prefix).
362
+ */
363
+ private compileSelectCore;
360
364
  protected compileUpdateAst(ast: UpdateQueryNode, ctx: CompilerContext): string;
361
365
  protected compileDeleteAst(ast: DeleteQueryNode, ctx: CompilerContext): string;
362
366
  /**
363
367
  * Default RETURNING compilation: no support.
364
368
  */
365
369
  protected compileReturning(returning: ColumnNode[] | undefined, _ctx: CompilerContext): string;
370
+ protected formatReturningColumns(returning: ColumnNode[]): string;
366
371
  /**
367
372
  * DISTINCT clause. Override for DISTINCT ON support.
368
373
  */
@@ -383,6 +388,7 @@ declare abstract class SqlDialectBase extends Dialect {
383
388
  protected compilePagination(ast: SelectQueryNode, _orderByClause: string): string;
384
389
  protected compileCtes(ast: SelectQueryNode, ctx: CompilerContext): string;
385
390
  protected stripTrailingSemicolon(sql: string): string;
391
+ protected wrapSetOperand(sql: string): string;
386
392
  }
387
393
 
388
394
  /**
@@ -443,6 +449,11 @@ declare class SqlServerDialect extends Dialect {
443
449
  protected compileInsertAst(ast: InsertQueryNode, ctx: CompilerContext): string;
444
450
  protected compileUpdateAst(ast: UpdateQueryNode, ctx: CompilerContext): string;
445
451
  protected compileDeleteAst(ast: DeleteQueryNode, ctx: CompilerContext): string;
452
+ private compileSelectCore;
453
+ private compileOrderBy;
454
+ private compilePagination;
455
+ private compileCtes;
456
+ private wrapSetOperand;
446
457
  }
447
458
 
448
459
  /**
@@ -466,6 +477,7 @@ declare class SqliteDialect extends SqlDialectBase {
466
477
  */
467
478
  protected compileJsonPath(node: JsonPathNode): string;
468
479
  protected compileReturning(returning: ColumnNode[] | undefined, ctx: CompilerContext): string;
480
+ supportsReturning(): boolean;
469
481
  }
470
482
 
471
483
  /**
@@ -489,6 +501,7 @@ declare class PostgresDialect extends SqlDialectBase {
489
501
  */
490
502
  protected compileJsonPath(node: JsonPathNode): string;
491
503
  protected compileReturning(returning: ColumnNode[] | undefined, ctx: CompilerContext): string;
504
+ supportsReturning(): boolean;
492
505
  }
493
506
 
494
507
  interface DatabaseColumn {
@@ -881,6 +894,7 @@ declare class DefaultHasManyCollection<TChild> implements HasManyCollection<TChi
881
894
  clear(): void;
882
895
  private get relationKey();
883
896
  private hydrateFromCache;
897
+ toJSON(): TChild[];
884
898
  }
885
899
 
886
900
  type Rows$1 = Record<string, any>;
@@ -902,6 +916,7 @@ declare class DefaultBelongsToReference<TParent> implements BelongsToReference<T
902
916
  set(data: Partial<TParent> | TParent | null): TParent | null;
903
917
  private get relationKey();
904
918
  private populateFromHydrationCache;
919
+ toJSON(): TParent | null;
905
920
  }
906
921
 
907
922
  type Rows = Record<string, any>[];
@@ -928,6 +943,7 @@ declare class DefaultManyToManyCollection<TTarget> implements ManyToManyCollecti
928
943
  private get relationKey();
929
944
  private get targetKey();
930
945
  private hydrateFromCache;
946
+ toJSON(): TTarget[];
931
947
  }
932
948
 
933
949
  declare function executeHydrated<TTable extends TableDef>(ctx: OrmContext, qb: SelectQueryBuilder<any, TTable>): Promise<Entity<TTable>[]>;