drizzle-team/drizzle-orm · error · Error
values() must be called with at least one value
Error message
values() must be called with at least one value
What it means
Error "values() must be called with at least one value" thrown in drizzle-team/drizzle-orm.
Source
Thrown at drizzle-orm/src/gel-core/query-builders/insert.ts:86
/** @internal */
setToken(token?: NeonAuthToken) {
this.authToken = token;
return this;
}
overridingSystemValue(): Omit<GelInsertBuilder<TTable, TQueryResult, true>, 'overridingSystemValue'> {
this.overridingSystemValue_ = true;
return this as any;
}
values(value: GelInsertValue<TTable, OverrideT>): GelInsertBase<TTable, TQueryResult>;
values(values: GelInsertValue<TTable, OverrideT>[]): GelInsertBase<TTable, TQueryResult>;
values(
values: GelInsertValue<TTable, OverrideT> | GelInsertValue<TTable, OverrideT>[],
): GelInsertBase<TTable, TQueryResult> {
values = Array.isArray(values) ? values : [values];
if (values.length === 0) {
throw new Error('values() must be called with at least one value');
}
const mappedValues = values.map((entry) => {
const result: Record<string, Param | SQL> = {};
const cols = this.table[Table.Symbol.Columns];
for (const colKey of Object.keys(entry)) {
const colValue = entry[colKey as keyof typeof entry];
result[colKey] = is(colValue, SQL) ? colValue : new Param(colValue, cols[colKey]);
}
return result;
});
return new GelInsertBase(
this.table,
mappedValues,
this.session,
this.dialect,
this.withList,
false,View on GitHub (pinned to b7862528fd)
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.
When it happens
Trigger: Calling .values() on a Gel insert builder with an empty array or no rows.
Common situations: Inserting a dynamically built rows array that ended up empty; mapping over an empty input list without a guard.
AI-assisted analysis of drizzle-team/drizzle-orm@b7862528fd (2026-08-03).
Data as JSON: /data/errors/793b4c55fd4ce7c6.json.
Report an issue: GitHub.