buildSetOperationQuery() — drizzle-orm Function Reference
Architecture documentation for the buildSetOperationQuery() function in dialect.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 86302f6e_1e27_c030_415e_a06b92a0e3f1["buildSetOperationQuery()"] 9c5eee4c_4b78_a585_4038_d710de212097["MySqlDialect"] 86302f6e_1e27_c030_415e_a06b92a0e3f1 -->|defined in| 9c5eee4c_4b78_a585_4038_d710de212097 3da984c5_cedc_6ee4_6ea2_52428870cfec["buildSetOperations()"] 3da984c5_cedc_6ee4_6ea2_52428870cfec -->|calls| 86302f6e_1e27_c030_415e_a06b92a0e3f1 9c41dd69_aefd_e482_6f36_cf99188bba37["getSQL()"] 86302f6e_1e27_c030_415e_a06b92a0e3f1 -->|calls| 9c41dd69_aefd_e482_6f36_cf99188bba37 style 86302f6e_1e27_c030_415e_a06b92a0e3f1 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
drizzle-orm/src/mysql-core/dialect.ts lines 448–491
buildSetOperationQuery({
leftSelect,
setOperator: { type, isAll, rightSelect, limit, orderBy, offset },
}: { leftSelect: SQL; setOperator: MySqlSelectConfig['setOperators'][number] }): SQL {
const leftChunk = sql`(${leftSelect.getSQL()}) `;
const rightChunk = sql`(${rightSelect.getSQL()})`;
let orderBySql;
if (orderBy && orderBy.length > 0) {
const orderByValues: (SQL<unknown> | Name)[] = [];
// The next bit is necessary because the sql operator replaces ${table.column} with `table`.`column`
// which is invalid MySql syntax, Table from one of the SELECTs cannot be used in global ORDER clause
for (const orderByUnit of orderBy) {
if (is(orderByUnit, MySqlColumn)) {
orderByValues.push(sql.identifier(this.casing.getColumnCasing(orderByUnit)));
} else if (is(orderByUnit, SQL)) {
for (let i = 0; i < orderByUnit.queryChunks.length; i++) {
const chunk = orderByUnit.queryChunks[i];
if (is(chunk, MySqlColumn)) {
orderByUnit.queryChunks[i] = sql.identifier(this.casing.getColumnCasing(chunk));
}
}
orderByValues.push(sql`${orderByUnit}`);
} else {
orderByValues.push(sql`${orderByUnit}`);
}
}
orderBySql = sql` order by ${sql.join(orderByValues, sql`, `)} `;
}
const limitSql = typeof limit === 'object' || (typeof limit === 'number' && limit >= 0)
? sql` limit ${limit}`
: undefined;
const operatorChunk = sql.raw(`${type} ${isAll ? 'all ' : ''}`);
const offsetSql = offset ? sql` offset ${offset}` : undefined;
return sql`${leftChunk}${operatorChunk}${rightChunk}${orderBySql}${limitSql}${offsetSql}`;
}
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does buildSetOperationQuery() do?
buildSetOperationQuery() is a function in the drizzle-orm codebase, defined in drizzle-orm/src/mysql-core/dialect.ts.
Where is buildSetOperationQuery() defined?
buildSetOperationQuery() is defined in drizzle-orm/src/mysql-core/dialect.ts at line 448.
What does buildSetOperationQuery() call?
buildSetOperationQuery() calls 1 function(s): getSQL.
What calls buildSetOperationQuery()?
buildSetOperationQuery() is called by 1 function(s): buildSetOperations.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free