PaulGilmartin / django-pgpubsub

A distributed task processing framework for Django built on top of the Postgres NOTIFY/LISTEN protocol.
Other
245 stars 12 forks source link

Fixes DB columns to model fields translation in deserialization #52

Closed romank0 closed 1 year ago

romank0 commented 1 year ago

This is based on https://github.com/Opus10/django-pgpubsub/pull/49

Problem

When the field in the model has _id in the end (that is named like order_id) such field is not deserialized correctly and is always empty.

Cause

This is caused by the code in the deserialization that attempts to handle the difference between model fields names and DB column names specifically for the associations which usually are named like order by the underlying DB column name is order_id. The code just cuts _id off and uses the result as a field name.

This works correctly for the association fields but breaks when the field name geniunly ends with _id but is not an association.

Solution

Use the column name from the django model meta for the translation.

PaulGilmartin commented 1 year ago

@romank0 Would you mind rebasing this with master now that https://github.com/Opus10/django-pgpubsub/pull/49 is merged :) ?

romank0 commented 1 year ago

@PaulGilmartin done