Skip to content
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

#308 Use Django's Cast function #309

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Aug 14, 2024

  1. etianen#308 Use Django's Cast function

    Using `RawSQL` with `model._meta.pk.db_column` will add a verbatim SQL expression into the query. In this case, a reference to the primary key column, although without the proper table alias. This leads to a SQL error for QuerySets which already have a JOIN due to an ambiguous column (e.g. `id`).
    Use Django's `Cast` function with the `id` property to cast the primary key of the model into a string, which will automatically de-alias `pk` to the name of primary key field and use the correct table alias in the resulting query.
    Johann Schmitz committed Aug 14, 2024
    Configuration menu
    Copy the full SHA
    3a75627 View commit details
    Browse the repository at this point in the history