metal-orm 1.0.45 → 1.0.46

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.
Files changed (47) hide show
  1. package/dist/index.cjs +72 -4
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +72 -4
  4. package/dist/index.d.ts +72 -4
  5. package/dist/index.js +69 -4
  6. package/dist/index.js.map +1 -1
  7. package/package.json +1 -1
  8. package/src/core/ast/adapters.ts +2 -1
  9. package/src/core/ddl/dialects/base-schema-dialect.ts +2 -1
  10. package/src/core/ddl/dialects/mssql-schema-dialect.ts +10 -23
  11. package/src/core/ddl/dialects/mysql-schema-dialect.ts +10 -24
  12. package/src/core/ddl/dialects/postgres-schema-dialect.ts +10 -23
  13. package/src/core/ddl/dialects/render-reference.test.ts +2 -1
  14. package/src/core/ddl/dialects/sqlite-schema-dialect.ts +9 -23
  15. package/src/core/ddl/introspect/catalogs/postgres.ts +2 -1
  16. package/src/core/ddl/introspect/mssql.ts +17 -1
  17. package/src/core/ddl/introspect/postgres.ts +2 -1
  18. package/src/core/ddl/introspect/sqlite.ts +2 -1
  19. package/src/core/ddl/schema-dialect.ts +2 -1
  20. package/src/core/ddl/schema-diff.ts +2 -1
  21. package/src/core/ddl/schema-generator.ts +2 -1
  22. package/src/core/ddl/schema-types.ts +2 -1
  23. package/src/core/ddl/sql-writing.ts +2 -1
  24. package/src/core/functions/datetime.ts +2 -1
  25. package/src/core/functions/numeric.ts +2 -1
  26. package/src/core/functions/text.ts +2 -1
  27. package/src/decorators/{column.ts → column-decorator.ts} +4 -1
  28. package/src/decorators/index.ts +1 -1
  29. package/src/index.ts +2 -1
  30. package/src/orm/entity-metadata.ts +2 -1
  31. package/src/orm/lazy-batch.ts +2 -1
  32. package/src/orm/orm-session.ts +2 -1
  33. package/src/query-builder/column-selector.ts +2 -1
  34. package/src/query-builder/delete.ts +2 -1
  35. package/src/query-builder/insert.ts +2 -1
  36. package/src/query-builder/query-ast-service.ts +2 -1
  37. package/src/query-builder/relation-projection-helper.ts +2 -1
  38. package/src/query-builder/relation-service.ts +2 -1
  39. package/src/query-builder/select/predicate-facet.ts +2 -1
  40. package/src/query-builder/select/projection-facet.ts +2 -1
  41. package/src/query-builder/select-helpers.ts +2 -1
  42. package/src/query-builder/select.ts +2 -1
  43. package/src/query-builder/update.ts +2 -1
  44. package/src/schema/{column.ts → column-types.ts} +317 -290
  45. package/src/schema/table-guards.ts +1 -1
  46. package/src/schema/table.ts +1 -1
  47. package/src/schema/types.ts +10 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metal-orm",
3
- "version": "1.0.45",
3
+ "version": "1.0.46",
4
4
  "type": "module",
5
5
  "types": "./dist/index.d.ts",
6
6
  "engines": {
@@ -1,4 +1,4 @@
1
- import { ColumnDef } from '../../schema/column.js';
1
+ import { ColumnDef } from '../../schema/column-types.js';
2
2
  import { TableDef } from '../../schema/table.js';
3
3
  import { ColumnRef, TableRef } from './types.js';
4
4
 
@@ -25,3 +25,4 @@ export const toTableRef = (table: TableRef | TableDef): TableRef => ({
25
25
  schema: table.schema,
26
26
  alias: hasAlias(table) ? table.alias : undefined
27
27
  });
28
+
@@ -1,6 +1,6 @@
1
1
  import { SchemaDialect, DialectName } from '../schema-dialect.js';
2
2
  import { formatLiteral, quoteQualified, LiteralFormatter } from '../sql-writing.js';
3
- import { ColumnDef, ForeignKeyReference } from '../../../schema/column.js';
3
+ import { ColumnDef, ForeignKeyReference } from '../../../schema/column-types.js';
4
4
  import { IndexDef, TableDef } from '../../../schema/table.js';
5
5
  import { DatabaseTable, DatabaseColumn, ColumnDiff } from '../schema-types.js';
6
6
 
@@ -93,3 +93,4 @@ export abstract class BaseSchemaDialect implements SchemaDialect {
93
93
  return false;
94
94
  }
95
95
  }
96
+
@@ -1,7 +1,7 @@
1
1
  import { BaseSchemaDialect } from './base-schema-dialect.js';
2
2
  import { deriveIndexName } from '../naming-strategy.js';
3
3
  import { renderIndexColumns, createLiteralFormatter } from '../sql-writing.js';
4
- import { ColumnDef } from '../../../schema/column.js';
4
+ import { ColumnDef, normalizeColumnType, renderTypeWithArgs } from '../../../schema/column-types.js';
5
5
  import { IndexDef, TableDef } from '../../../schema/table.js';
6
6
  import { ColumnDiff, DatabaseColumn, DatabaseTable } from '../schema-types.js';
7
7
  import { DialectName } from '../schema-dialect.js';
@@ -24,54 +24,43 @@ export class MSSqlSchemaDialect extends BaseSchemaDialect {
24
24
  }
25
25
 
26
26
  renderColumnType(column: ColumnDef): string {
27
- switch (column.type) {
28
- case 'INT':
29
- case 'INTEGER':
27
+ const override = column.dialectTypes?.[this.name] ?? column.dialectTypes?.default;
28
+ if (override) {
29
+ return renderTypeWithArgs(override, column.args);
30
+ }
31
+
32
+ const type = normalizeColumnType(column.type);
33
+ switch (type) {
30
34
  case 'int':
31
35
  case 'integer':
32
36
  return 'INT';
33
- case 'BIGINT':
34
37
  case 'bigint':
35
38
  return 'BIGINT';
36
- case 'UUID':
37
39
  case 'uuid':
38
40
  return 'UNIQUEIDENTIFIER';
39
- case 'BOOLEAN':
40
41
  case 'boolean':
41
42
  return 'BIT';
42
- case 'JSON':
43
43
  case 'json':
44
44
  return 'NVARCHAR(MAX)';
45
- case 'DECIMAL':
46
45
  case 'decimal':
47
46
  return column.args?.length ? `DECIMAL(${column.args[0]},${column.args[1] ?? 0})` : 'DECIMAL(18,0)';
48
- case 'FLOAT':
49
47
  case 'float':
50
- case 'DOUBLE':
51
48
  case 'double':
52
49
  return 'FLOAT';
53
- case 'TIMESTAMPTZ':
54
50
  case 'timestamptz':
55
- case 'TIMESTAMP':
56
51
  case 'timestamp':
57
- case 'DATETIME':
58
52
  case 'datetime':
59
53
  return 'DATETIME2';
60
- case 'DATE':
61
54
  case 'date':
62
55
  return 'DATE';
63
- case 'VARCHAR':
64
56
  case 'varchar':
65
57
  return column.args?.length ? `NVARCHAR(${column.args[0]})` : 'NVARCHAR(255)';
66
- case 'TEXT':
67
58
  case 'text':
68
59
  return 'NVARCHAR(MAX)';
69
- case 'BINARY':
70
60
  case 'binary': {
71
61
  const length = column.args?.[0];
72
62
  return length !== undefined ? `BINARY(${length})` : 'BINARY(255)';
73
63
  }
74
- case 'VARBINARY':
75
64
  case 'varbinary': {
76
65
  const length = column.args?.[0];
77
66
  if (typeof length === 'string' && length.toLowerCase() === 'max') {
@@ -79,16 +68,13 @@ export class MSSqlSchemaDialect extends BaseSchemaDialect {
79
68
  }
80
69
  return length !== undefined ? `VARBINARY(${length})` : 'VARBINARY(255)';
81
70
  }
82
- case 'BLOB':
83
71
  case 'blob':
84
- case 'BYTEA':
85
72
  case 'bytea':
86
73
  return 'VARBINARY(MAX)';
87
- case 'ENUM':
88
74
  case 'enum':
89
75
  return 'NVARCHAR(255)';
90
76
  default:
91
- return String(column.type).toUpperCase();
77
+ return renderTypeWithArgs(String(type).toUpperCase(), column.args);
92
78
  }
93
79
  }
94
80
 
@@ -142,3 +128,4 @@ export class MSSqlSchemaDialect extends BaseSchemaDialect {
142
128
  return undefined;
143
129
  }
144
130
  }
131
+
@@ -1,7 +1,7 @@
1
1
  import { BaseSchemaDialect } from './base-schema-dialect.js';
2
2
  import { deriveIndexName } from '../naming-strategy.js';
3
3
  import { renderIndexColumns, escapeSqlString, createLiteralFormatter } from '../sql-writing.js';
4
- import { ColumnDef } from '../../../schema/column.js';
4
+ import { ColumnDef, normalizeColumnType, renderTypeWithArgs } from '../../../schema/column-types.js';
5
5
  import { IndexDef, TableDef } from '../../../schema/table.js';
6
6
  import { ColumnDiff, DatabaseColumn, DatabaseTable } from '../schema-types.js';
7
7
  import { renderColumnDefinition } from '../schema-generator.js';
@@ -25,69 +25,54 @@ export class MySqlSchemaDialect extends BaseSchemaDialect {
25
25
  }
26
26
 
27
27
  renderColumnType(column: ColumnDef): string {
28
- switch (column.type) {
29
- case 'INT':
30
- case 'INTEGER':
28
+ const override = column.dialectTypes?.[this.name] ?? column.dialectTypes?.default;
29
+ if (override) {
30
+ return renderTypeWithArgs(override, column.args);
31
+ }
32
+
33
+ const type = normalizeColumnType(column.type);
34
+ switch (type) {
31
35
  case 'int':
32
36
  case 'integer':
33
37
  return 'INT';
34
- case 'BIGINT':
35
38
  case 'bigint':
36
39
  return 'BIGINT';
37
- case 'UUID':
38
40
  case 'uuid':
39
41
  return 'CHAR(36)';
40
- case 'BOOLEAN':
41
42
  case 'boolean':
42
43
  return 'TINYINT(1)';
43
- case 'JSON':
44
44
  case 'json':
45
45
  return 'JSON';
46
- case 'DECIMAL':
47
46
  case 'decimal':
48
47
  return column.args?.length ? `DECIMAL(${column.args[0]},${column.args[1] ?? 0})` : 'DECIMAL';
49
- case 'FLOAT':
50
48
  case 'float':
51
49
  return column.args?.length ? `FLOAT(${column.args[0]})` : 'FLOAT';
52
- case 'DOUBLE':
53
50
  case 'double':
54
51
  return 'DOUBLE';
55
- case 'TIMESTAMPTZ':
56
52
  case 'timestamptz':
57
- return 'TIMESTAMP';
58
- case 'TIMESTAMP':
59
53
  case 'timestamp':
60
54
  return 'TIMESTAMP';
61
- case 'DATETIME':
62
55
  case 'datetime':
63
56
  return 'DATETIME';
64
- case 'DATE':
65
57
  case 'date':
66
58
  return 'DATE';
67
- case 'VARCHAR':
68
59
  case 'varchar':
69
60
  return column.args?.length ? `VARCHAR(${column.args[0]})` : 'VARCHAR(255)';
70
- case 'TEXT':
71
61
  case 'text':
72
62
  return 'TEXT';
73
- case 'BINARY':
74
63
  case 'binary':
75
64
  return column.args?.length ? `BINARY(${column.args[0]})` : 'BINARY(255)';
76
- case 'VARBINARY':
77
65
  case 'varbinary':
78
66
  return column.args?.length ? `VARBINARY(${column.args[0]})` : 'VARBINARY(255)';
79
- case 'BLOB':
80
67
  case 'blob':
81
- case 'BYTEA':
82
68
  case 'bytea':
83
69
  return 'BLOB';
84
- case 'ENUM':
85
70
  case 'enum':
86
71
  return column.args && Array.isArray(column.args) && column.args.length
87
72
  ? `ENUM(${column.args.map((v: string) => `'${escapeSqlString(v)}'`).join(',')})`
88
73
  : 'ENUM';
89
74
  default:
90
- return String(column.type).toUpperCase();
75
+ return renderTypeWithArgs(String(type).toUpperCase(), column.args);
91
76
  }
92
77
  }
93
78
 
@@ -132,3 +117,4 @@ export class MySqlSchemaDialect extends BaseSchemaDialect {
132
117
  return [`ALTER TABLE ${this.formatTableName(table)} MODIFY COLUMN ${rendered.sql};`];
133
118
  }
134
119
  }
120
+
@@ -1,7 +1,7 @@
1
1
  import { BaseSchemaDialect } from './base-schema-dialect.js';
2
2
  import { deriveIndexName } from '../naming-strategy.js';
3
3
  import { renderIndexColumns, createLiteralFormatter } from '../sql-writing.js';
4
- import { ColumnDef, ForeignKeyReference } from '../../../schema/column.js';
4
+ import { ColumnDef, ForeignKeyReference, normalizeColumnType, renderTypeWithArgs } from '../../../schema/column-types.js';
5
5
  import { IndexDef, TableDef } from '../../../schema/table.js';
6
6
  import { ColumnDiff, DatabaseColumn, DatabaseTable } from '../schema-types.js';
7
7
  import { DialectName } from '../schema-dialect.js';
@@ -24,64 +24,50 @@ export class PostgresSchemaDialect extends BaseSchemaDialect {
24
24
  }
25
25
 
26
26
  renderColumnType(column: ColumnDef): string {
27
- switch (column.type) {
28
- case 'INT':
29
- case 'INTEGER':
27
+ const override = column.dialectTypes?.[this.name] ?? column.dialectTypes?.default;
28
+ if (override) {
29
+ return renderTypeWithArgs(override, column.args);
30
+ }
31
+
32
+ const type = normalizeColumnType(column.type);
33
+ switch (type) {
30
34
  case 'int':
31
35
  case 'integer':
32
36
  return 'integer';
33
- case 'BIGINT':
34
37
  case 'bigint':
35
38
  return 'bigint';
36
- case 'UUID':
37
39
  case 'uuid':
38
40
  return 'uuid';
39
- case 'BOOLEAN':
40
41
  case 'boolean':
41
42
  return 'boolean';
42
- case 'JSON':
43
43
  case 'json':
44
44
  return 'jsonb';
45
- case 'DECIMAL':
46
45
  case 'decimal':
47
46
  return column.args?.length ? `numeric(${column.args[0]}, ${column.args[1] ?? 0})` : 'numeric';
48
- case 'FLOAT':
49
47
  case 'float':
50
- case 'DOUBLE':
51
48
  case 'double':
52
49
  return 'double precision';
53
- case 'TIMESTAMPTZ':
54
50
  case 'timestamptz':
55
51
  return 'timestamptz';
56
- case 'TIMESTAMP':
57
52
  case 'timestamp':
58
53
  return 'timestamp';
59
- case 'DATE':
60
54
  case 'date':
61
55
  return 'date';
62
- case 'DATETIME':
63
56
  case 'datetime':
64
57
  return 'timestamp';
65
- case 'VARCHAR':
66
58
  case 'varchar':
67
59
  return column.args?.length ? `varchar(${column.args[0]})` : 'varchar';
68
- case 'TEXT':
69
60
  case 'text':
70
61
  return 'text';
71
- case 'ENUM':
72
62
  case 'enum':
73
63
  return 'text';
74
- case 'BINARY':
75
64
  case 'binary':
76
- case 'VARBINARY':
77
65
  case 'varbinary':
78
- case 'BLOB':
79
66
  case 'blob':
80
- case 'BYTEA':
81
67
  case 'bytea':
82
68
  return 'bytea';
83
69
  default:
84
- return String(column.type).toLowerCase();
70
+ return renderTypeWithArgs(String(type).toLowerCase(), column.args);
85
71
  }
86
72
  }
87
73
 
@@ -164,3 +150,4 @@ export class PostgresSchemaDialect extends BaseSchemaDialect {
164
150
  return undefined;
165
151
  }
166
152
  }
153
+
@@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest';
2
2
  import { BaseSchemaDialect } from './base-schema-dialect.js';
3
3
  import { PostgresSchemaDialect } from './postgres-schema-dialect.js';
4
4
  import { TableDef } from '../../../schema/table.js';
5
- import { ForeignKeyReference } from '../../../schema/column.js';
5
+ import { ForeignKeyReference } from '../../../schema/column-types.js';
6
6
  import { createLiteralFormatter } from '../sql-writing.js';
7
7
 
8
8
  class DummySchemaDialect extends BaseSchemaDialect {
@@ -67,3 +67,4 @@ describe('renderReference deferrable handling', () => {
67
67
  expect(sql).not.toContain('DEFERRABLE INITIALLY DEFERRED');
68
68
  });
69
69
  });
70
+
@@ -1,7 +1,7 @@
1
1
  import { BaseSchemaDialect } from './base-schema-dialect.js';
2
2
  import { deriveIndexName } from '../naming-strategy.js';
3
3
  import { renderIndexColumns, resolvePrimaryKey, createLiteralFormatter } from '../sql-writing.js';
4
- import { ColumnDef } from '../../../schema/column.js';
4
+ import { ColumnDef, normalizeColumnType, renderTypeWithArgs } from '../../../schema/column-types.js';
5
5
  import { IndexDef, TableDef } from '../../../schema/table.js';
6
6
  import { ColumnDiff, DatabaseColumn, DatabaseTable } from '../schema-types.js';
7
7
  import { DialectName } from '../schema-dialect.js';
@@ -24,52 +24,37 @@ export class SQLiteSchemaDialect extends BaseSchemaDialect {
24
24
  }
25
25
 
26
26
  renderColumnType(column: ColumnDef): string {
27
- switch (column.type) {
28
- case 'INT':
29
- case 'INTEGER':
27
+ const override = column.dialectTypes?.[this.name] ?? column.dialectTypes?.default;
28
+ if (override) {
29
+ return renderTypeWithArgs(override, column.args);
30
+ }
31
+
32
+ const type = normalizeColumnType(column.type);
33
+ switch (type) {
30
34
  case 'int':
31
35
  case 'integer':
32
- case 'BIGINT':
33
36
  case 'bigint':
34
37
  return 'INTEGER';
35
- case 'BOOLEAN':
36
38
  case 'boolean':
37
39
  return 'INTEGER';
38
- case 'DECIMAL':
39
40
  case 'decimal':
40
- case 'FLOAT':
41
41
  case 'float':
42
- case 'DOUBLE':
43
42
  case 'double':
44
43
  return 'REAL';
45
- case 'DATE':
46
44
  case 'date':
47
- case 'DATETIME':
48
45
  case 'datetime':
49
- case 'TIMESTAMP':
50
46
  case 'timestamp':
51
- case 'TIMESTAMPTZ':
52
47
  case 'timestamptz':
53
48
  return 'TEXT';
54
- case 'VARCHAR':
55
49
  case 'varchar':
56
- case 'TEXT':
57
50
  case 'text':
58
- case 'JSON':
59
51
  case 'json':
60
- case 'UUID':
61
52
  case 'uuid':
62
- return 'TEXT';
63
- case 'ENUM':
64
53
  case 'enum':
65
54
  return 'TEXT';
66
- case 'BINARY':
67
55
  case 'binary':
68
- case 'VARBINARY':
69
56
  case 'varbinary':
70
- case 'BLOB':
71
57
  case 'blob':
72
- case 'BYTEA':
73
58
  case 'bytea':
74
59
  return 'BLOB';
75
60
  default:
@@ -134,3 +119,4 @@ export class SQLiteSchemaDialect extends BaseSchemaDialect {
134
119
  return `SQLite ALTER COLUMN is not supported; rebuild table ${key} to change column ${column.name}.`;
135
120
  }
136
121
  }
122
+
@@ -1,5 +1,5 @@
1
1
  import { defineTable } from '../../../../schema/table.js';
2
- import { col } from '../../../../schema/column.js';
2
+ import { col } from '../../../../schema/column-types.js';
3
3
 
4
4
  /** Table definition for information_schema.columns, providing metadata about table columns. */
5
5
  export const PgInformationSchemaColumns = defineTable(
@@ -143,3 +143,4 @@ export default {
143
143
  PgIndex,
144
144
  PgAttribute
145
145
  };
146
+
@@ -61,7 +61,23 @@ export const mssqlIntrospector: SchemaIntrospector = {
61
61
  sch.name AS table_schema,
62
62
  t.name AS table_name,
63
63
  c.name AS column_name,
64
- ty.name AS data_type,
64
+ LOWER(ty.name)
65
+ + CASE
66
+ WHEN LOWER(ty.name) IN ('varchar', 'char', 'varbinary', 'binary', 'nvarchar', 'nchar') THEN
67
+ '('
68
+ + (
69
+ CASE
70
+ WHEN c.max_length = -1 THEN 'max'
71
+ WHEN LOWER(ty.name) IN ('nvarchar', 'nchar') THEN CAST(c.max_length / 2 AS varchar(10))
72
+ ELSE CAST(c.max_length AS varchar(10))
73
+ END
74
+ )
75
+ + ')'
76
+ WHEN LOWER(ty.name) IN ('decimal', 'numeric') THEN
77
+ '(' + CAST(c.precision AS varchar(10)) + ',' + CAST(c.scale AS varchar(10)) + ')'
78
+ ELSE
79
+ ''
80
+ END AS data_type,
65
81
  c.is_nullable,
66
82
  c.is_identity,
67
83
  object_definition(c.default_object_id) AS column_default
@@ -1,7 +1,7 @@
1
1
  import type { SchemaIntrospector, IntrospectOptions } from './types.js';
2
2
  import { shouldIncludeTable } from './utils.js';
3
3
  import { DatabaseSchema, DatabaseTable, DatabaseIndex, DatabaseColumn } from '../schema-types.js';
4
- import type { ReferentialAction } from '../../../schema/column.js';
4
+ import type { ReferentialAction } from '../../../schema/column-types.js';
5
5
  import type { IntrospectContext } from './context.js';
6
6
  import { PgInformationSchemaColumns } from './catalogs/postgres.js';
7
7
  import { PgKeyColumnUsage, PgTableConstraints, PgConstraintColumnUsage, PgReferentialConstraints } from './catalogs/postgres.js';
@@ -311,3 +311,4 @@ export const postgresIntrospector: SchemaIntrospector = {
311
311
  return { tables };
312
312
  }
313
313
  };
314
+
@@ -1,7 +1,7 @@
1
1
  import { SchemaIntrospector, IntrospectOptions } from './types.js';
2
2
  import { queryRows, shouldIncludeTable } from './utils.js';
3
3
  import { DatabaseSchema, DatabaseTable, DatabaseIndex } from '../schema-types.js';
4
- import { ReferentialAction } from '../../../schema/column.js';
4
+ import { ReferentialAction } from '../../../schema/column-types.js';
5
5
  import { DbExecutor } from '../../execution/db-executor.js';
6
6
 
7
7
  /** Row type for SQLite table list from sqlite_master. */
@@ -131,3 +131,4 @@ export const sqliteIntrospector: SchemaIntrospector = {
131
131
  return { tables };
132
132
  }
133
133
  };
134
+
@@ -1,5 +1,5 @@
1
1
  import type { TableDef, IndexDef } from '../../schema/table.js';
2
- import type { ColumnDef, ForeignKeyReference } from '../../schema/column.js';
2
+ import type { ColumnDef, ForeignKeyReference } from '../../schema/column-types.js';
3
3
  import type { DatabaseTable, DatabaseColumn, ColumnDiff } from './schema-types.js';
4
4
 
5
5
  /** The name of a database dialect. */
@@ -53,3 +53,4 @@ export interface SchemaDialect {
53
53
  /** Returns a warning message for altering a column. */
54
54
  warnAlterColumn?(table: TableDef, column: ColumnDef, actualColumn: DatabaseColumn, diff: ColumnDiff): string | undefined;
55
55
  }
56
+
@@ -1,5 +1,5 @@
1
1
  import { TableDef } from '../../schema/table.js';
2
- import { ColumnDef } from '../../schema/column.js';
2
+ import { ColumnDef } from '../../schema/column-types.js';
3
3
  import type { DbExecutor } from '../execution/db-executor.js';
4
4
  import { SchemaDialect } from './schema-dialect.js';
5
5
  import { deriveIndexName } from './naming-strategy.js';
@@ -231,3 +231,4 @@ export const synchronizeSchema = async (
231
231
  }
232
232
  return plan;
233
233
  };
234
+
@@ -1,5 +1,5 @@
1
1
  import type { TableDef } from '../../schema/table.js';
2
- import type { ColumnDef } from '../../schema/column.js';
2
+ import type { ColumnDef } from '../../schema/column-types.js';
3
3
  import type { SchemaDialect } from './schema-dialect.js';
4
4
  import { resolvePrimaryKey } from './sql-writing.js';
5
5
  import { DialectName } from './schema-dialect.js';
@@ -168,3 +168,4 @@ const orderTablesByDependencies = (tables: TableDef[]): TableDef[] => {
168
168
 
169
169
  // Re-export DialectName for backward compatibility
170
170
  export type { DialectName };
171
+
@@ -1,4 +1,4 @@
1
- import { ForeignKeyReference } from '../../schema/column.js';
1
+ import { ForeignKeyReference } from '../../schema/column-types.js';
2
2
  import { IndexColumn } from '../../schema/table.js';
3
3
 
4
4
  /** Represents the differences detected in a database column's properties. */
@@ -50,3 +50,4 @@ export interface DatabaseTable {
50
50
  export interface DatabaseSchema {
51
51
  tables: DatabaseTable[];
52
52
  }
53
+
@@ -1,5 +1,5 @@
1
1
  import type { TableDef, IndexColumn } from '../../schema/table.js';
2
- import type { ColumnDef, RawDefaultValue } from '../../schema/column.js';
2
+ import type { ColumnDef, RawDefaultValue } from '../../schema/column-types.js';
3
3
 
4
4
  /**
5
5
  * Minimal surface for anything that can quote identifiers.
@@ -168,3 +168,4 @@ export const resolvePrimaryKey = (table: TableDef): string[] => {
168
168
  .filter(col => col.primary)
169
169
  .map(col => col.name);
170
170
  };
171
+
@@ -1,6 +1,6 @@
1
1
  // Pure AST Builders - No Dialect Logic Here!
2
2
 
3
- import { ColumnDef } from '../../schema/column.js';
3
+ import { ColumnDef } from '../../schema/column-types.js';
4
4
  import { columnOperand, valueToOperand } from '../ast/expression-builders.js';
5
5
  import { FunctionNode, OperandNode, isOperandNode } from '../ast/expression.js';
6
6
 
@@ -155,3 +155,4 @@ export const weekOfYear = (date: OperandInput): FunctionNode => fn('WEEK_OF_YEAR
155
155
  * @returns A FunctionNode representing the DATE_TRUNC SQL function.
156
156
  */
157
157
  export const dateTrunc = (part: OperandInput, date: OperandInput): FunctionNode => fn('DATE_TRUNC', [part, date]);
158
+
@@ -1,6 +1,6 @@
1
1
  // Pure AST Builders - No Dialect Logic Here!
2
2
 
3
- import { ColumnDef } from '../../schema/column.js';
3
+ import { ColumnDef } from '../../schema/column-types.js';
4
4
  import { columnOperand, valueToOperand } from '../ast/expression-builders.js';
5
5
  import { FunctionNode, OperandNode, isOperandNode } from '../ast/expression.js';
6
6
 
@@ -243,3 +243,4 @@ export const trunc = (value: OperandInput, decimals?: OperandInput): FunctionNod
243
243
  */
244
244
  export const truncate = (value: OperandInput, decimals: OperandInput): FunctionNode =>
245
245
  fn('TRUNCATE', [value, decimals]);
246
+
@@ -1,6 +1,6 @@
1
1
  // Pure AST Builders - No Dialect Logic Here!
2
2
 
3
- import { ColumnDef } from '../../schema/column.js';
3
+ import { ColumnDef } from '../../schema/column-types.js';
4
4
  import { columnOperand, valueToOperand } from '../ast/expression-builders.js';
5
5
  import { FunctionNode, OperandNode, isOperandNode } from '../ast/expression.js';
6
6
 
@@ -207,3 +207,4 @@ export const rpad = (value: OperandInput, len: OperandInput, pad: OperandInput):
207
207
  * @returns A FunctionNode representing the SPACE SQL function.
208
208
  */
209
209
  export const space = (count: OperandInput): FunctionNode => fn('SPACE', [count]);
210
+
@@ -1,4 +1,4 @@
1
- import { ColumnDef, ColumnType } from '../schema/column.js';
1
+ import { ColumnDef, ColumnType } from '../schema/column-types.js';
2
2
  import {
3
3
  addColumnMetadata,
4
4
  EntityConstructor,
@@ -18,6 +18,7 @@ import {
18
18
  export interface ColumnOptions {
19
19
  type: ColumnType;
20
20
  args?: ColumnDef['args'];
21
+ dialectTypes?: ColumnDef['dialectTypes'];
21
22
  notNull?: boolean;
22
23
  primary?: boolean;
23
24
  tsType?: ColumnDef['tsType'];
@@ -34,6 +35,7 @@ const normalizeColumnInput = (input: ColumnInput): ColumnDefLike => {
34
35
  const column: ColumnDefLike = {
35
36
  type: asOptions.type ?? asDefinition.type,
36
37
  args: asOptions.args ?? asDefinition.args,
38
+ dialectTypes: asOptions.dialectTypes ?? asDefinition.dialectTypes,
37
39
  notNull: asOptions.notNull ?? asDefinition.notNull,
38
40
  primary: asOptions.primary ?? asDefinition.primary,
39
41
  tsType: asDefinition.tsType ?? asOptions.tsType,
@@ -130,3 +132,4 @@ export function PrimaryKey(definition: ColumnInput) {
130
132
  normalized.primary = true;
131
133
  return Column(normalized);
132
134
  }
135
+
@@ -2,6 +2,6 @@
2
2
  * Decorators for defining entities, columns, and relations in Metal ORM.
3
3
  */
4
4
  export * from './entity.js';
5
- export * from './column.js';
5
+ export * from './column-decorator.js';
6
6
  export * from './relations.js';
7
7
  export * from './bootstrap.js';
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from './schema/table.js';
2
- export * from './schema/column.js';
2
+ export * from './schema/column-types.js';
3
3
  export * from './schema/relation.js';
4
4
  export * from './schema/types.js';
5
5
  export * from './query-builder/select.js';
@@ -52,3 +52,4 @@ export * from './core/execution/executors/mssql-executor.js';
52
52
 
53
53
  // NEW: first-class pooling integration
54
54
  export * from './orm/pooled-executor-factory.js';
55
+
@@ -1,4 +1,4 @@
1
- import { ColumnDef } from '../schema/column.js';
1
+ import { ColumnDef } from '../schema/column-types.js';
2
2
  import { defineTable, TableDef, TableHooks } from '../schema/table.js';
3
3
  import { CascadeMode, RelationKinds } from '../schema/relation.js';
4
4
 
@@ -262,3 +262,4 @@ export const buildTableDef = <TColumns extends Record<string, ColumnDefLike>>(me
262
262
  meta.table = table;
263
263
  return table;
264
264
  };
265
+
@@ -4,7 +4,7 @@ import { SelectQueryBuilder } from '../query-builder/select.js';
4
4
  import { inList, LiteralNode } from '../core/ast/expression.js';
5
5
  import { EntityContext } from './entity-context.js';
6
6
  import type { QueryResult } from '../core/execution/db-executor.js';
7
- import { ColumnDef } from '../schema/column.js';
7
+ import { ColumnDef } from '../schema/column-types.js';
8
8
  import { findPrimaryKey } from '../query-builder/hydration-planner.js';
9
9
 
10
10
  /**
@@ -307,3 +307,4 @@ export const loadBelongsToManyRelation = async (
307
307
 
308
308
  return result;
309
309
  };
310
+
@@ -3,7 +3,7 @@ import { eq } from '../core/ast/expression.js';
3
3
  import type { DbExecutor } from '../core/execution/db-executor.js';
4
4
  import { SelectQueryBuilder } from '../query-builder/select.js';
5
5
  import { findPrimaryKey } from '../query-builder/hydration-planner.js';
6
- import type { ColumnDef } from '../schema/column.js';
6
+ import type { ColumnDef } from '../schema/column-types.js';
7
7
  import type { TableDef } from '../schema/table.js';
8
8
  import { EntityInstance } from '../schema/types.js';
9
9
  import { RelationDef } from '../schema/relation.js';
@@ -464,3 +464,4 @@ const buildRelationChangeEntry = (
464
464
  relation,
465
465
  change
466
466
  });
467
+