django-postgresql-dag icon indicating copy to clipboard operation
django-postgresql-dag copied to clipboard

Compatibilty with Django Polymorphic

Open HtheChemist opened this issue 2 years ago • 0 comments

The raw query generated by the Node are incompatible with Django Polymorphic because the .get_pk_name() method return the field name (e.g. parent_ptr) and not the field attribute name (e.g. parent_ptr_id).

Changing:

        def get_pk_name(self):
            """Sometimes we set a field other than 'pk' for the primary key.
            This method is used to get the correct primary key field name for the
            model so that raw queries return the correct information."""
            return self._meta.pk.name

to:

        def get_pk_name(self):
            """Sometimes we set a field other than 'pk' for the primary key.
            This method is used to get the correct primary key field name for the
            model so that raw queries return the correct information."""
            return self._meta.pk.attname

solve the problem.

The repo seems to not be up to date with the PyPi repo so I am hesitant to make a pull request.

HtheChemist avatar Feb 09 '23 16:02 HtheChemist