metal-orm 1.0.94 → 1.0.96

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 CHANGED
@@ -208,6 +208,8 @@ __export(index_exports, {
208
208
  generateSchemaSqlFor: () => generateSchemaSqlFor,
209
209
  getColumn: () => getColumn,
210
210
  getColumnMap: () => getColumnMap,
211
+ getColumnType: () => getColumnType,
212
+ getDateKind: () => getDateKind,
211
213
  getDecoratorMetadata: () => getDecoratorMetadata,
212
214
  getDeterministicComponentName: () => getDeterministicComponentName,
213
215
  getOpenApiVersionForDialect: () => getOpenApiVersionForDialect,
@@ -8296,8 +8298,10 @@ var InsertQueryBuilder = class _InsertQueryBuilder {
8296
8298
  };
8297
8299
 
8298
8300
  // src/query-builder/update-query-state.ts
8301
+ var LITERAL_VALUE_TYPES = ["string", "number", "boolean", "Date", "null"];
8299
8302
  var isUpdateValue = (value) => {
8300
8303
  if (value === null) return true;
8304
+ if (value instanceof Date) return true;
8301
8305
  switch (typeof value) {
8302
8306
  case "string":
8303
8307
  case "number":
@@ -8340,8 +8344,9 @@ var UpdateQueryState = class _UpdateQueryState {
8340
8344
  withSet(values) {
8341
8345
  const assignments = Object.entries(values).map(([column, rawValue]) => {
8342
8346
  if (!isUpdateValue(rawValue)) {
8347
+ const allowedTypes = [...LITERAL_VALUE_TYPES, "OperandNode"];
8343
8348
  throw new Error(
8344
- `Invalid update value for column "${column}": only primitives, null, or OperandNodes are allowed`
8349
+ `Invalid update value for column "${column}": only ${allowedTypes.join(", ")} are allowed`
8345
8350
  );
8346
8351
  }
8347
8352
  return {
@@ -12650,6 +12655,31 @@ var Orm = class {
12650
12655
  }
12651
12656
  };
12652
12657
 
12658
+ // src/orm/column-introspection.ts
12659
+ var getColumnDefFromTarget = (target, column) => {
12660
+ if (typeof target === "function") {
12661
+ const meta = getEntityMetadata(target);
12662
+ if (!meta?.columns) return void 0;
12663
+ return meta.columns[column];
12664
+ }
12665
+ const table = target;
12666
+ return table.columns[column];
12667
+ };
12668
+ var getColumnType = (target, column) => {
12669
+ const col2 = getColumnDefFromTarget(target, column);
12670
+ if (!col2?.type) return void 0;
12671
+ return normalizeColumnType(col2.type);
12672
+ };
12673
+ var getDateKind = (target, column) => {
12674
+ const type = getColumnType(target, column);
12675
+ if (!type) return void 0;
12676
+ if (type === "date") return "date";
12677
+ if (type === "datetime" || type === "timestamp" || type === "timestamptz") {
12678
+ return "date-time";
12679
+ }
12680
+ return void 0;
12681
+ };
12682
+
12653
12683
  // src/orm/jsonify.ts
12654
12684
  var jsonify = (value) => {
12655
12685
  const record = value;
@@ -15475,6 +15505,8 @@ function pagedResponseToOpenApiSchema(itemSchema) {
15475
15505
  generateSchemaSqlFor,
15476
15506
  getColumn,
15477
15507
  getColumnMap,
15508
+ getColumnType,
15509
+ getDateKind,
15478
15510
  getDecoratorMetadata,
15479
15511
  getDeterministicComponentName,
15480
15512
  getOpenApiVersionForDialect,