@drzl/validation-core 2.1.0 → 3.0.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
@@ -100362,12 +100362,11 @@ function validateAffix(affix, schemaSuffix) {
100362
100362
  }
100363
100363
 
100364
100364
  // src/index.ts
100365
- function isGeneratedColumn(c5, primaryKeyColumns) {
100366
- return c5.isGenerated || primaryKeyColumns.includes(c5.name);
100365
+ function isGeneratedColumn(c5, _primaryKeyColumns = []) {
100366
+ return c5.isGenerated;
100367
100367
  }
100368
100368
  function insertColumns(table) {
100369
- const pkCols = table.primaryKey?.columns ?? [];
100370
- return table.columns.filter((c5) => !isGeneratedColumn(c5, pkCols));
100369
+ return table.columns.filter((c5) => !isGeneratedColumn(c5));
100371
100370
  }
100372
100371
  function updateColumns(table) {
100373
100372
  const pkCols = table.primaryKey?.columns ?? [];
package/dist/index.d.cts CHANGED
@@ -223,7 +223,21 @@ interface ValidationRenderer<TOptions extends ValidationGenerateOptions = Valida
223
223
  renderIndex?(analysis: Analysis, opts?: TOptions): string;
224
224
  generate(opts: TOptions): Promise<string[]>;
225
225
  }
226
- declare function isGeneratedColumn(c: Column, primaryKeyColumns: string[]): boolean;
226
+ /**
227
+ * Whether the database generates this column's value, so it cannot be written.
228
+ *
229
+ * `primaryKeyColumns` is accepted for backwards compatibility and no longer consulted. It used
230
+ * to make every primary key count as generated, which dropped it from the insert schema whether
231
+ * or not the database supplied it. Right for a MySQL autoincrement column; wrong for a Postgres
232
+ * `integer('id').primaryKey()`, which Postgres does not generate, and for any natural key such
233
+ * as `text('slug').primaryKey()`. Those inserts became impossible to express: the required
234
+ * column was simply absent, with no way to provide it.
235
+ *
236
+ * Being a key says nothing about who supplies the value. `isGenerated` marks a column that
237
+ * cannot be written; `hasDefault` marks one that need not be, and those stay in the schema as
238
+ * optional.
239
+ */
240
+ declare function isGeneratedColumn(c: Column, _primaryKeyColumns?: string[]): boolean;
227
241
  declare function insertColumns(table: Table): Column[];
228
242
  declare function updateColumns(table: Table): Column[];
229
243
  declare function selectColumns(table: Table): Column[];
package/dist/index.d.ts CHANGED
@@ -223,7 +223,21 @@ interface ValidationRenderer<TOptions extends ValidationGenerateOptions = Valida
223
223
  renderIndex?(analysis: Analysis, opts?: TOptions): string;
224
224
  generate(opts: TOptions): Promise<string[]>;
225
225
  }
226
- declare function isGeneratedColumn(c: Column, primaryKeyColumns: string[]): boolean;
226
+ /**
227
+ * Whether the database generates this column's value, so it cannot be written.
228
+ *
229
+ * `primaryKeyColumns` is accepted for backwards compatibility and no longer consulted. It used
230
+ * to make every primary key count as generated, which dropped it from the insert schema whether
231
+ * or not the database supplied it. Right for a MySQL autoincrement column; wrong for a Postgres
232
+ * `integer('id').primaryKey()`, which Postgres does not generate, and for any natural key such
233
+ * as `text('slug').primaryKey()`. Those inserts became impossible to express: the required
234
+ * column was simply absent, with no way to provide it.
235
+ *
236
+ * Being a key says nothing about who supplies the value. `isGenerated` marks a column that
237
+ * cannot be written; `hasDefault` marks one that need not be, and those stay in the schema as
238
+ * optional.
239
+ */
240
+ declare function isGeneratedColumn(c: Column, _primaryKeyColumns?: string[]): boolean;
227
241
  declare function insertColumns(table: Table): Column[];
228
242
  declare function updateColumns(table: Table): Column[];
229
243
  declare function selectColumns(table: Table): Column[];
package/dist/index.js CHANGED
@@ -166,12 +166,11 @@ function validateAffix(affix, schemaSuffix) {
166
166
  }
167
167
 
168
168
  // src/index.ts
169
- function isGeneratedColumn(c, primaryKeyColumns) {
170
- return c.isGenerated || primaryKeyColumns.includes(c.name);
169
+ function isGeneratedColumn(c, _primaryKeyColumns = []) {
170
+ return c.isGenerated;
171
171
  }
172
172
  function insertColumns(table) {
173
- const pkCols = table.primaryKey?.columns ?? [];
174
- return table.columns.filter((c) => !isGeneratedColumn(c, pkCols));
173
+ return table.columns.filter((c) => !isGeneratedColumn(c));
175
174
  }
176
175
  function updateColumns(table) {
177
176
  const pkCols = table.primaryKey?.columns ?? [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drzl/validation-core",
3
- "version": "2.1.0",
3
+ "version": "3.0.0",
4
4
  "private": false,
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -11,7 +11,7 @@
11
11
  ],
12
12
  "sideEffects": false,
13
13
  "dependencies": {
14
- "@drzl/analyzer": "^1.4.0"
14
+ "@drzl/analyzer": "^1.5.0"
15
15
  },
16
16
  "devDependencies": {
17
17
  "tsup": "^8.5.0",