drawdb icon indicating copy to clipboard operation
drawdb copied to clipboard

feat(validation): Add circular type dependency check

Open 22Yash opened this issue 4 months ago • 1 comments

Problem: Users can create a circular dependency between custom types (e.g., Type A references Type B, and Type B references Type A). This structure is invalid and cannot be correctly generated in a schema but was not being flagged as an issue.

Furthermore, an initial attempt to implement this failed due to a case mismatch between how custom type names are defined (type_a) and how they are referenced by fields (TYPE_A).

Solution:

  1. Implemented Circular Dependency Check: Added a Depth First Search (DFS) algorithm within getIssues.js to detect cycles within the diagram.types graph.
  2. Added Translation Key: Included the new translation key circular_type_dependency in en.js.
  3. Fixed Casing Discrepancy (Name Normalization): Normalized all custom type names and references to uppercase within the DFS logic. This ensures the lookup works reliably regardless of the casing in the stored data, correctly identifying the circular reference.

Validation/Testing: Created two custom types, type_A and type_B.

  • type_A has a field referencing TYPE_B.
  • type_B has a field referencing TYPE_A.

Expected Result (Achieved): The Issues panel now correctly displays "Issues (1)" and the message: "Circular type dependency detected in: type_A." Screenshot 2025-10-10 144920

22Yash avatar Oct 10 '25 09:10 22Yash

@22Yash is attempting to deploy a commit to the dottle's projects Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Oct 10 '25 09:10 vercel[bot]