@drzl/analyzer 1.10.0 → 1.11.0

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
@@ -651,6 +651,8 @@ var _SchemaAnalyzer = class _SchemaAnalyzer {
651
651
  }
652
652
  const ev = col?.enumValues;
653
653
  const nullable = !col?.notNull && !col?.config?.notNull;
654
+ const rawDefault = col?.default;
655
+ const defaultValue = rawDefault !== void 0 && !(rawDefault && typeof rawDefault === "object" && "queryChunks" in rawDefault) ? rawDefault : void 0;
654
656
  const generatedIdentity = col?.generatedIdentity;
655
657
  const isGenerated = !!(col?.generated || generatedIdentity?.type === "always" || col?.isGenerated);
656
658
  const hasDefault = col?.hasDefault === true || col?.default !== void 0 || col?.config?.default !== void 0 || col?.defaultFn !== void 0 || isGenerated;
@@ -678,6 +680,7 @@ var _SchemaAnalyzer = class _SchemaAnalyzer {
678
680
  defaultExpression: void 0,
679
681
  references,
680
682
  enumValues: Array.isArray(ev) ? ev : void 0,
683
+ ...defaultValue !== void 0 ? { defaultValue } : {},
681
684
  ...constraints,
682
685
  ...v1 ?? {}
683
686
  });
package/dist/index.d.cts CHANGED
@@ -72,6 +72,15 @@ interface Column {
72
72
  * checking at all. See `COLUMN_FORMATS` in `@drzl/validation-core`.
73
73
  */
74
74
  format?: 'uuid' | 'numeric';
75
+ /**
76
+ * The column's default, when it is a literal a schema can reproduce.
77
+ *
78
+ * `.default('GB')` stores a plain JS value. `defaultNow()`, `defaultRandom()` and any
79
+ * `sql` default store an object the database evaluates, and `$defaultFn` stores a function
80
+ * Drizzle calls at insert time. A schema guessing at either of those would produce a different
81
+ * value than the one actually stored, so only the literal case is carried.
82
+ */
83
+ defaultValue?: unknown;
75
84
  /**
76
85
  * Array depth for a column declared with `.array()`, absent when the column is a scalar.
77
86
  *
package/dist/index.d.ts CHANGED
@@ -72,6 +72,15 @@ interface Column {
72
72
  * checking at all. See `COLUMN_FORMATS` in `@drzl/validation-core`.
73
73
  */
74
74
  format?: 'uuid' | 'numeric';
75
+ /**
76
+ * The column's default, when it is a literal a schema can reproduce.
77
+ *
78
+ * `.default('GB')` stores a plain JS value. `defaultNow()`, `defaultRandom()` and any
79
+ * `sql` default store an object the database evaluates, and `$defaultFn` stores a function
80
+ * Drizzle calls at insert time. A schema guessing at either of those would produce a different
81
+ * value than the one actually stored, so only the literal case is carried.
82
+ */
83
+ defaultValue?: unknown;
75
84
  /**
76
85
  * Array depth for a column declared with `.array()`, absent when the column is a scalar.
77
86
  *
package/dist/index.js CHANGED
@@ -612,6 +612,8 @@ var _SchemaAnalyzer = class _SchemaAnalyzer {
612
612
  }
613
613
  const ev = col?.enumValues;
614
614
  const nullable = !col?.notNull && !col?.config?.notNull;
615
+ const rawDefault = col?.default;
616
+ const defaultValue = rawDefault !== void 0 && !(rawDefault && typeof rawDefault === "object" && "queryChunks" in rawDefault) ? rawDefault : void 0;
615
617
  const generatedIdentity = col?.generatedIdentity;
616
618
  const isGenerated = !!(col?.generated || generatedIdentity?.type === "always" || col?.isGenerated);
617
619
  const hasDefault = col?.hasDefault === true || col?.default !== void 0 || col?.config?.default !== void 0 || col?.defaultFn !== void 0 || isGenerated;
@@ -639,6 +641,7 @@ var _SchemaAnalyzer = class _SchemaAnalyzer {
639
641
  defaultExpression: void 0,
640
642
  references,
641
643
  enumValues: Array.isArray(ev) ? ev : void 0,
644
+ ...defaultValue !== void 0 ? { defaultValue } : {},
642
645
  ...constraints,
643
646
  ...v1 ?? {}
644
647
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drzl/analyzer",
3
- "version": "1.10.0",
3
+ "version": "1.11.0",
4
4
  "private": false,
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",