{"id":"793b4c55fd4ce7c6","repo":"drizzle-team/drizzle-orm","slug":"values-must-be-called-with-at-least-one-value","errorCode":null,"errorMessage":"values() must be called with at least one value","messagePattern":"values\\(\\) must be called with at least one value","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"drizzle-orm/src/gel-core/query-builders/insert.ts","lineNumber":86,"sourceCode":"\t/** @internal */\n\tsetToken(token?: NeonAuthToken) {\n\t\tthis.authToken = token;\n\t\treturn this;\n\t}\n\n\toverridingSystemValue(): Omit<GelInsertBuilder<TTable, TQueryResult, true>, 'overridingSystemValue'> {\n\t\tthis.overridingSystemValue_ = true;\n\t\treturn this as any;\n\t}\n\n\tvalues(value: GelInsertValue<TTable, OverrideT>): GelInsertBase<TTable, TQueryResult>;\n\tvalues(values: GelInsertValue<TTable, OverrideT>[]): GelInsertBase<TTable, TQueryResult>;\n\tvalues(\n\t\tvalues: GelInsertValue<TTable, OverrideT> | GelInsertValue<TTable, OverrideT>[],\n\t): GelInsertBase<TTable, TQueryResult> {\n\t\tvalues = Array.isArray(values) ? values : [values];\n\t\tif (values.length === 0) {\n\t\t\tthrow new Error('values() must be called with at least one value');\n\t\t}\n\t\tconst mappedValues = values.map((entry) => {\n\t\t\tconst result: Record<string, Param | SQL> = {};\n\t\t\tconst cols = this.table[Table.Symbol.Columns];\n\t\t\tfor (const colKey of Object.keys(entry)) {\n\t\t\t\tconst colValue = entry[colKey as keyof typeof entry];\n\t\t\t\tresult[colKey] = is(colValue, SQL) ? colValue : new Param(colValue, cols[colKey]);\n\t\t\t}\n\t\t\treturn result;\n\t\t});\n\n\t\treturn new GelInsertBase(\n\t\t\tthis.table,\n\t\t\tmappedValues,\n\t\t\tthis.session,\n\t\t\tthis.dialect,\n\t\t\tthis.withList,\n\t\t\tfalse,","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/drizzle-team/drizzle-orm/blob/b7862528fd8fc39bc2653a6c18dad7c1f4e68d10/drizzle-orm/src/gel-core/query-builders/insert.ts#L68-L104","documentation":"Error \"values() must be called with at least one value\" thrown in drizzle-team/drizzle-orm.","triggerScenarios":"Calling .values() on a Gel insert builder with an empty array or no rows.","commonSituations":"Inserting a dynamically built rows array that ended up empty; mapping over an empty input list without a guard.","solutions":["Pass at least one row object to .values(), e.g. .values({ col: 1 }) or a non-empty array of rows.","Guard the insert so it is only executed when there is data to insert."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"b7862528fd8fc39bc2653a6c18dad7c1f4e68d10","analyzedAt":"2026-08-03T18:11:14.318Z","schemaVersion":2}