-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fields using db_column
are unsupported
#95
Comments
I can work around the issue with an alias cte = With(
cls.objects.annotate(node=F('treenode_id')).values("node").filter(user_id=uid)
)
cte.join(CouchDocCte, treenode_id=cte.col.node).with_cte(cte) This will use the alias |
That's a good workaround. I wonder if For reference, here's a formatted version of the SQL from above with a comment detailing what was expected. WITH RECURSIVE "cte" AS (
SELECT "userorgs"."oid"
FROM "userorgs"
WHERE "userorgs"."uid" = %s
)
SELECT "couchdoc"."rid", ...
FROM "couchdoc"
INNER JOIN "cte" ON "couchdoc"."treenode_id" = ("cte"."treenode_id")
-- expected: "couchdoc"."treenode_id" = ("cte"."oid") |
Given an M2M model which uses a
db_column
, the SQL code generated bydjango_cte
does not account for the column name. I'd expect a CTE join to join onoid
in the example below as that is thedb_column
value. But the join is specified ontreenode_id
.The issue arises, I think, here:
django-cte/django_cte/meta.py
Lines 61 to 68 in 61d5311
The code generated by django_cte does not account for the
db_column
Raises
The code generated by the queryset was:
The text was updated successfully, but these errors were encountered: