isRelationCyclic() — drizzle-orm Function Reference
Architecture documentation for the isRelationCyclic() function in index.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD d8406fd4_31dc_5e40_765e_d2ea7f0d3134["isRelationCyclic()"] 0fabdd81_61c9_bb7c_7ddf_dde7a6071abc["index.ts"] d8406fd4_31dc_5e40_765e_d2ea7f0d3134 -->|defined in| 0fabdd81_61c9_bb7c_7ddf_dde7a6071abc a33c8a66_8c96_661c_8767_a3a71961208b["getPostgresInfo()"] a33c8a66_8c96_661c_8767_a3a71961208b -->|calls| d8406fd4_31dc_5e40_765e_d2ea7f0d3134 7bfa7bb3_181b_ecad_deb4_686cdb9b0d10["getMySqlInfo()"] 7bfa7bb3_181b_ecad_deb4_686cdb9b0d10 -->|calls| d8406fd4_31dc_5e40_765e_d2ea7f0d3134 e8a71082_205b_2757_2e0b_855628ebd207["getSqliteInfo()"] e8a71082_205b_2757_2e0b_855628ebd207 -->|calls| d8406fd4_31dc_5e40_765e_d2ea7f0d3134 style d8406fd4_31dc_5e40_765e_d2ea7f0d3134 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
drizzle-seed/src/index.ts lines 832–864
const isRelationCyclic = (
startRel: RelationWithReferences,
) => {
// self relation
if (startRel.table === startRel.refTable) return false;
// DFS
const targetTable = startRel.table;
const queue = [startRel];
let path: string[] = [];
while (queue.length !== 0) {
const currRel = queue.shift();
if (path.includes(currRel!.table)) {
const idx = path.indexOf(currRel!.table);
path = path.slice(0, idx);
}
path.push(currRel!.table);
for (const rel of currRel!.refTableRels) {
// self relation
if (rel.table === rel.refTable) continue;
if (rel.refTable === targetTable) return true;
// found cycle, but not the one we are looking for
if (path.includes(rel.refTable)) continue;
queue.unshift(rel);
}
}
return false;
};
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does isRelationCyclic() do?
isRelationCyclic() is a function in the drizzle-orm codebase, defined in drizzle-seed/src/index.ts.
Where is isRelationCyclic() defined?
isRelationCyclic() is defined in drizzle-seed/src/index.ts at line 832.
What calls isRelationCyclic()?
isRelationCyclic() is called by 3 function(s): getMySqlInfo, getPostgresInfo, getSqliteInfo.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free