diff --git a/dist/parser/insert-values-parser.d.ts b/dist/parser/insert-values-parser.d.ts index f77f26d0b37d60ab50c784e5c430e7e0c60c3caf..0c8759ce1894193e4df7f9fde633ad9ee7ad0af7 100644 --- a/dist/parser/insert-values-parser.d.ts +++ b/dist/parser/insert-values-parser.d.ts @@ -3,6 +3,7 @@ import { type ValueExpression } from './value-parser.js'; import { ValuesNode } from '../operation-node/values-node.js'; import type { NonNullableInsertKeys, NullableInsertKeys, InsertType } from '../util/column-type.js'; import { type ExpressionBuilder } from '../expression/expression-builder.js'; +import type { KyselyTypeError } from '../util/type-error.js'; export type InsertObject = { [C in NonNullableInsertKeys]: ValueExpression>; } & { @@ -11,4 +12,10 @@ export type InsertObject = { export type InsertObjectOrList = InsertObject | ReadonlyArray>; export type InsertObjectOrListFactory = (eb: ExpressionBuilder) => InsertObjectOrList; export type InsertExpression = InsertObjectOrList | InsertObjectOrListFactory; +type AllInsertRowKeys = R extends unknown ? keyof R : never; +type OptionalInsertRowKeys = { + [K in keyof R]-?: undefined extends R[K] ? K : never; +}[keyof R]; +type HeterogeneousInsertRowsError = KyselyTypeError<`every row must explicitly set the key '${K & string}', otherwise null is inserted for the rows missing it`>; +export type HomogeneousInsertRows = [AllInsertRowKeys] extends [keyof R] ? [OptionalInsertRowKeys] extends [never] ? unknown : HeterogeneousInsertRowsError> : HeterogeneousInsertRowsError, keyof R>>; export declare function parseInsertExpression(arg: InsertExpression): [ReadonlyArray, ValuesNode]; diff --git a/dist/plugin/parse-json-results/parse-json-results-plugin.js b/dist/plugin/parse-json-results/parse-json-results-plugin.js index f5d150373a5e36034044b6ba4e5840a7f7a3e725..7700d5ca3888c6ab8c8fad8494ba9dced24e258a 100644 --- a/dist/plugin/parse-json-results/parse-json-results-plugin.js +++ b/dist/plugin/parse-json-results/parse-json-results-plugin.js @@ -114,7 +114,6 @@ function parseString(str, jsonPath, options) { throw error; } // built-in naive heuristic should keep going despite errors given there might be false positives in detection. - console.error(error); return str; } } diff --git a/dist/query-builder/insert-query-builder.d.ts b/dist/query-builder/insert-query-builder.d.ts index c75dfa47aad5eb505a241896067e60e536ea0561..2621cf967f242f7d405eecc95bc7befa8749aedd 100644 --- a/dist/query-builder/insert-query-builder.d.ts +++ b/dist/query-builder/insert-query-builder.d.ts @@ -1,7 +1,7 @@ import type { OperationNodeSource } from '../operation-node/operation-node-source.js'; import type { CompiledQuery } from '../query-compiler/compiled-query.js'; import { type SelectExpression, type SelectCallback } from '../parser/select-parser.js'; -import { type InsertExpression } from '../parser/insert-values-parser.js'; +import { type HomogeneousInsertRows, type InsertExpression, type InsertObject, type InsertObjectOrListFactory } from '../parser/insert-values-parser.js'; import { InsertQueryNode } from '../operation-node/insert-query-node.js'; import type { NarrowPartial, SimplifyResult, SimplifySingleResult } from '../util/type-utils.js'; import { type UpdateObjectExpression } from '../parser/update-set-parser.js'; @@ -202,7 +202,8 @@ export declare class InsertQueryBuilder implemen * ) * ``` */ - values(insert: InsertExpression): InsertQueryBuilder; + values(insert: InsertObject | InsertObjectOrListFactory): InsertQueryBuilder; + values>(insert: readonly R[] & HomogeneousInsertRows): InsertQueryBuilder; /** * Sets the columns to insert. *