django-hashid-field icon indicating copy to clipboard operation
django-hashid-field copied to clipboard

Add logic to in lookup to select only the PK on subqueries

Open camuthig opened this issue 2 years ago • 1 comments
trafficstars

The default In lookup prep performs logic to make it such that developers do not have to explicitly call values('id') or values('pk') when writing subqueries on the ID value. This backports the same logic implemented today in the core In lookup class to make it work the same way for hashid fields.

The clear_ordering function is noted in Django 3 to have side effect bugs regarding certain array subqueries in Postgresql, and the clearing of the ordering was not added to the In class until Django 4 anyway, so the order clearing is only included in Django > 4.0 by default to keep behaviors consistent.

See django/django source for core implementation

camuthig avatar Dec 02 '22 23:12 camuthig

Thank you for the PR, this looks good. I'll merge and publish soon, pending response on your other PR #76.

nshafer avatar Dec 12 '22 18:12 nshafer