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

onConflictDoNothing() — drizzle-orm Function Reference

Architecture documentation for the onConflictDoNothing() function in insert.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  f6e79c9c_ccf6_bb2d_26a0_5bed8c783fda["onConflictDoNothing()"]
  2a1c8405_186b_c3e8_f4eb_b5df91726669["PgInsertBase"]
  f6e79c9c_ccf6_bb2d_26a0_5bed8c783fda -->|defined in| 2a1c8405_186b_c3e8_f4eb_b5df91726669
  style f6e79c9c_ccf6_bb2d_26a0_5bed8c783fda fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-orm/src/pg-core/query-builders/insert.ts lines 323–338

	onConflictDoNothing(
		config: { target?: IndexColumn | IndexColumn[]; where?: SQL } = {},
	): PgInsertWithout<this, TDynamic, 'onConflictDoNothing' | 'onConflictDoUpdate'> {
		if (config.target === undefined) {
			this.config.onConflict = sql`do nothing`;
		} else {
			let targetColumn = '';
			targetColumn = Array.isArray(config.target)
				? config.target.map((it) => this.dialect.escapeName(this.dialect.casing.getColumnCasing(it))).join(',')
				: this.dialect.escapeName(this.dialect.casing.getColumnCasing(config.target));

			const whereSql = config.where ? sql` where ${config.where}` : undefined;
			this.config.onConflict = sql`(${sql.raw(targetColumn)})${whereSql} do nothing`;
		}
		return this as any;
	}

Domain

Subdomains

Frequently Asked Questions

What does onConflictDoNothing() do?
onConflictDoNothing() is a function in the drizzle-orm codebase, defined in drizzle-orm/src/pg-core/query-builders/insert.ts.
Where is onConflictDoNothing() defined?
onConflictDoNothing() is defined in drizzle-orm/src/pg-core/query-builders/insert.ts at line 323.

Analyze Your Own Codebase

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

Try Supermodel Free