Skip to content

refactor: centralize circular query dependency detection#1032

Merged
nextchamp-saqib merged 1 commit intodevelopfrom
query-recursion
Apr 6, 2026
Merged

refactor: centralize circular query dependency detection#1032
nextchamp-saqib merged 1 commit intodevelopfrom
query-recursion

Conversation

@nextchamp-saqib
Copy link
Copy Markdown
Member

@nextchamp-saqib nextchamp-saqib commented Apr 6, 2026

Replaces 4 independent, ad-hoc circular reference guards with a unified approach:

  • New query_utils.py: shared graph utilities — extract_query_deps_from_operations, get_direct_dependencies, transitive_closure, find_cycle
  • Validate on save (InsightsQueryv3.validate): cycles are now caught before being persisted, with a full cycle path in the error message (e.g. "A" → "B" → "A")
  • IbisQueryBuilder.build(): owns the runtime recursion guard (via frappe.local) as a defensive fallback
  • get_source_tables(): rewritten using transitive_closure — drops the recursive visited parameter pattern
  • set_linked_queries(): simplified to a one-liner using extract_query_deps_from_operations
  • getLinkedQueries() (frontend): fixed a latent infinite-loop bug — adds a _visited Set to guard against cycles in already-loaded data
  • getEffectiveOperationsForDrillDown() (frontend): _visitedQueryNames: string[]_visitedQueries: Set<string> for O(1) lookups and consistent style

@nextchamp-saqib nextchamp-saqib changed the title fix: circular query references refactor: centralize circular query dependency detection Apr 6, 2026
@nextchamp-saqib nextchamp-saqib merged commit b03eb3b into develop Apr 6, 2026
5 checks passed
mergify bot pushed a commit that referenced this pull request Apr 6, 2026
nextchamp-saqib added a commit that referenced this pull request Apr 6, 2026
) (#1033)

(cherry picked from commit b03eb3b)

Co-authored-by: Saqib Ansari <nextchamp.saqib@gmail.com>
@nextchamp-saqib nextchamp-saqib deleted the query-recursion branch April 15, 2026 06:55
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 3.8.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant