Changes between Version 1 and Version 2 of Ticket #32449, comment 3
- Timestamp:
- Feb 16, 2021, 2:45:31 PM (4 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #32449, comment 3
v1 v2 8 8 {{{ 9 9 #!python 10 # nodes/models.py10 # graph/models.py 11 11 12 12 class Node(models.Model): … … 24 24 25 25 # b_qs is a really complex 'B' queryset 26 b_qs = b_qs.objects.select_related(' A').annotate(graph_child_count=RawSQL("""27 WITH RECURSIVE graph_children(id) AS (26 b_qs = b_qs.objects.select_related('a').annotate(graph_child_count=RawSQL(""" 27 WITH RECURSIVE children(id) AS ( 28 28 SELECT "e"."child_id" 29 FROM " nodes_edge" AS "e"30 WHERE "e"."parent_id" = " nodes_a"."node_id"29 FROM "graph_edge" AS "e" 30 WHERE "e"."parent_id" = "graph_a"."node_id" 31 31 UNION 32 32 SELECT "e"."child_id" 33 FROM " nodes_edge" AS "e", "graph_children"34 WHERE "e"."parent_id" = " graph_children"."id"33 FROM "graph_edge" AS "e", "children" 34 WHERE "e"."parent_id" = "children"."id" 35 35 ) SELECT COUNT(*) FROM "graph_children" 36 36 """, [])).filter(graph_child_count__lt=10).count()