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

buildUpdateQuery() — drizzle-orm Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  b6dba0b8_7a2e_9652_d94a_4567bdbe1d3b["buildUpdateQuery()"]
  f80973ef_149c_bd36_66ee_1e7e9024a9d5["GelDialect"]
  b6dba0b8_7a2e_9652_d94a_4567bdbe1d3b -->|defined in| f80973ef_149c_bd36_66ee_1e7e9024a9d5
  508f5cc1_d856_0ba4_7831_119c8e91ea8f["buildWithCTE()"]
  b6dba0b8_7a2e_9652_d94a_4567bdbe1d3b -->|calls| 508f5cc1_d856_0ba4_7831_119c8e91ea8f
  56b46121_6704_96e1_3367_d68ecf0742be["buildUpdateSet()"]
  b6dba0b8_7a2e_9652_d94a_4567bdbe1d3b -->|calls| 56b46121_6704_96e1_3367_d68ecf0742be
  3dcc15aa_317d_ff74_31aa_fc51c58a0b1c["buildFromTable()"]
  b6dba0b8_7a2e_9652_d94a_4567bdbe1d3b -->|calls| 3dcc15aa_317d_ff74_31aa_fc51c58a0b1c
  e14f6d94_0730_204f_0331_852853023bf3["buildJoins()"]
  b6dba0b8_7a2e_9652_d94a_4567bdbe1d3b -->|calls| e14f6d94_0730_204f_0331_852853023bf3
  e2fb541e_5197_4994_9f97_bb47abf659ff["buildSelection()"]
  b6dba0b8_7a2e_9652_d94a_4567bdbe1d3b -->|calls| e2fb541e_5197_4994_9f97_bb47abf659ff
  style b6dba0b8_7a2e_9652_d94a_4567bdbe1d3b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-orm/src/gel-core/dialect.ts lines 163–187

	buildUpdateQuery({ table, set, where, returning, withList, from, joins }: GelUpdateConfig): SQL {
		const withSql = this.buildWithCTE(withList);

		const tableName = table[GelTable.Symbol.Name];
		const tableSchema = table[GelTable.Symbol.Schema];
		const origTableName = table[GelTable.Symbol.OriginalName];
		const alias = tableName === origTableName ? undefined : tableName;
		const tableSql = sql`${tableSchema ? sql`${sql.identifier(tableSchema)}.` : undefined}${
			sql.identifier(origTableName)
		}${alias && sql` ${sql.identifier(alias)}`}`;

		const setSql = this.buildUpdateSet(table, set);

		const fromSql = from && sql.join([sql.raw(' from '), this.buildFromTable(from)]);

		const joinsSql = this.buildJoins(joins);

		const returningSql = returning
			? sql` returning ${this.buildSelection(returning, { isSingleTable: !from })}`
			: undefined;

		const whereSql = where ? sql` where ${where}` : undefined;

		return sql`${withSql}update ${tableSql} set ${setSql}${fromSql}${joinsSql}${whereSql}${returningSql}`;
	}

Domain

Subdomains

Frequently Asked Questions

What does buildUpdateQuery() do?
buildUpdateQuery() is a function in the drizzle-orm codebase, defined in drizzle-orm/src/gel-core/dialect.ts.
Where is buildUpdateQuery() defined?
buildUpdateQuery() is defined in drizzle-orm/src/gel-core/dialect.ts at line 163.
What does buildUpdateQuery() call?
buildUpdateQuery() calls 5 function(s): buildFromTable, buildJoins, buildSelection, buildUpdateSet, buildWithCTE.

Analyze Your Own Codebase

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

Try Supermodel Free