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 a10eef6b_871f_2873_5f7a_35a4a094e933["buildSetOperationQuery()"] f80973ef_149c_bd36_66ee_1e7e9024a9d5["GelDialect"] a10eef6b_871f_2873_5f7a_35a4a094e933 -->|defined in| f80973ef_149c_bd36_66ee_1e7e9024a9d5 896a4bfc_a0fe_c924_90a8_862a42b92dd8["buildSetOperations()"] 896a4bfc_a0fe_c924_90a8_862a42b92dd8 -->|calls| a10eef6b_871f_2873_5f7a_35a4a094e933 style a10eef6b_871f_2873_5f7a_35a4a094e933 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
drizzle-orm/src/gel-core/dialect.ts lines 463–506
buildSetOperationQuery({
leftSelect,
setOperator: { type, isAll, rightSelect, limit, orderBy, offset },
}: { leftSelect: SQL; setOperator: GelSelectConfig['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 Sql syntax, Table from one of the SELECTs cannot be used in global ORDER clause
for (const singleOrderBy of orderBy) {
if (is(singleOrderBy, GelColumn)) {
orderByValues.push(sql.identifier(singleOrderBy.name));
} else if (is(singleOrderBy, SQL)) {
for (let i = 0; i < singleOrderBy.queryChunks.length; i++) {
const chunk = singleOrderBy.queryChunks[i];
if (is(chunk, GelColumn)) {
singleOrderBy.queryChunks[i] = sql.identifier(chunk.name);
}
}
orderByValues.push(sql`${singleOrderBy}`);
} else {
orderByValues.push(sql`${singleOrderBy}`);
}
}
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
Called By
Source
Frequently Asked Questions
What does buildSetOperationQuery() do?
buildSetOperationQuery() is a function in the drizzle-orm codebase, defined in drizzle-orm/src/gel-core/dialect.ts.
Where is buildSetOperationQuery() defined?
buildSetOperationQuery() is defined in drizzle-orm/src/gel-core/dialect.ts at line 463.
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