Home / Function/ buildUpdateSet() — drizzle-orm Function Reference

buildUpdateSet() — drizzle-orm Function Reference

Architecture documentation for the buildUpdateSet() function in dialect.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  56b46121_6704_96e1_3367_d68ecf0742be["buildUpdateSet()"]
  f80973ef_149c_bd36_66ee_1e7e9024a9d5["GelDialect"]
  56b46121_6704_96e1_3367_d68ecf0742be -->|defined in| f80973ef_149c_bd36_66ee_1e7e9024a9d5
  b6dba0b8_7a2e_9652_d94a_4567bdbe1d3b["buildUpdateQuery()"]
  b6dba0b8_7a2e_9652_d94a_4567bdbe1d3b -->|calls| 56b46121_6704_96e1_3367_d68ecf0742be
  style 56b46121_6704_96e1_3367_d68ecf0742be fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-orm/src/gel-core/dialect.ts lines 141–161

	buildUpdateSet(table: GelTable, set: UpdateSet): SQL {
		const tableColumns = table[Table.Symbol.Columns];

		const columnNames = Object.keys(tableColumns).filter((colName) =>
			set[colName] !== undefined || tableColumns[colName]?.onUpdateFn !== undefined
		);

		const setSize = columnNames.length;
		return sql.join(columnNames.flatMap((colName, i) => {
			const col = tableColumns[colName]!;

			const onUpdateFnResult = col.onUpdateFn?.();
			const value = set[colName] ?? (is(onUpdateFnResult, SQL) ? onUpdateFnResult : sql.param(onUpdateFnResult, col));
			const res = sql`${sql.identifier(this.casing.getColumnCasing(col))} = ${value}`;

			if (i < setSize - 1) {
				return [res, sql.raw(', ')];
			}
			return [res];
		}));
	}

Domain

Subdomains

Called By

Frequently Asked Questions

What does buildUpdateSet() do?
buildUpdateSet() is a function in the drizzle-orm codebase, defined in drizzle-orm/src/gel-core/dialect.ts.
Where is buildUpdateSet() defined?
buildUpdateSet() is defined in drizzle-orm/src/gel-core/dialect.ts at line 141.
What calls buildUpdateSet()?
buildUpdateSet() is called by 1 function(s): buildUpdateQuery.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free