GeeWee / django-auto-prefetching

Automatic prefetching for Django
MIT License
231 stars 18 forks source link

Duplicate LEFT Join #62

Open Arti3DPlayer opened 1 year ago

Arti3DPlayer commented 1 year ago

In my serializer I have 6 same FK fields:

field = CustomSerializer(
        source="field", read_only=True
    )
field = CustomSerializer(
    source="field2", read_only=True
)

And django_auto_prefetching.prefetch(queryset, self.get_serializer_class()) generate 2 LEFT JOIN, that cause:

django.db.utils.OperationalError: (1116, 'Too many tables; MariaDB can only use 61 tables in a join')

Can we prevent duplicate JOIN by default?

GeeWee commented 1 year ago

Hah, that does sound like a lot of tables! I don't really use or maintain this project that actively anymore, but if someone wants to submit a PR with a test case, I'd love to accept it.

Arti3DPlayer commented 1 year ago

Did you find better alternative ?:) I found your library useful in all DRF projects:)

GeeWee commented 1 year ago

I did not, I just don't use Django in my day-to-day job anymore :) - Glad you like the library though!