metal-orm 1.0.95 → 1.0.97

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.js CHANGED
@@ -4699,9 +4699,15 @@ var hydrateRows = (rows, plan) => {
4699
4699
  }
4700
4700
  return seen;
4701
4701
  };
4702
+ const hasRelations = plan.relations.length > 0;
4702
4703
  for (const row of rows) {
4703
4704
  const rootId = row[plan.rootPrimaryKey];
4704
- if (rootId === void 0) continue;
4705
+ if (rootId === void 0 || rootId === null) {
4706
+ if (!hasRelations) {
4707
+ rootMap.set(Symbol(), createBaseRow(row, plan));
4708
+ }
4709
+ continue;
4710
+ }
4705
4711
  const parent = getOrCreateParent(row);
4706
4712
  if (!parent) continue;
4707
4713
  for (const rel of plan.relations) {
@@ -7939,8 +7945,10 @@ var InsertQueryBuilder = class _InsertQueryBuilder {
7939
7945
  };
7940
7946
 
7941
7947
  // src/query-builder/update-query-state.ts
7948
+ var LITERAL_VALUE_TYPES = ["string", "number", "boolean", "Date", "null"];
7942
7949
  var isUpdateValue = (value) => {
7943
7950
  if (value === null) return true;
7951
+ if (value instanceof Date) return true;
7944
7952
  switch (typeof value) {
7945
7953
  case "string":
7946
7954
  case "number":
@@ -7983,8 +7991,9 @@ var UpdateQueryState = class _UpdateQueryState {
7983
7991
  withSet(values) {
7984
7992
  const assignments = Object.entries(values).map(([column, rawValue]) => {
7985
7993
  if (!isUpdateValue(rawValue)) {
7994
+ const allowedTypes = [...LITERAL_VALUE_TYPES, "OperandNode"];
7986
7995
  throw new Error(
7987
- `Invalid update value for column "${column}": only primitives, null, or OperandNodes are allowed`
7996
+ `Invalid update value for column "${column}": only ${allowedTypes.join(", ")} are allowed`
7988
7997
  );
7989
7998
  }
7990
7999
  return {