jazzband / django-ddp

Django/PostgreSQL implementation of the Meteor server.
MIT License
167 stars 29 forks source link

Serializer fails for ForeignKey fields with db_column set to field name. #36

Open tysonclugg opened 8 years ago

tysonclugg commented 8 years ago

The default serializer fails to return a value for the foo field of the Bar model in following:

from django.db import models

class Foo(models.Model):
    name = models.CharField(max_length=10)

class Bar(models.Model):
    foo = models.ForeignKey('Foo', db_column='foo')
codyparker commented 8 years ago

@tysonclugg - I wanted to take a look at this issue today, but I can't recreate the problem. It works just fine for me when using db_column on a ForeignKey.

What error or problem do you see with the serializer with this?

tysonclugg commented 8 years ago

Line https://github.com/jazzband/django-ddp/blame/develop/dddp/api.py#L435 sets fields[field.column] but then line https://github.com/jazzband/django-ddp/blame/develop/dddp/api.py#L438 runs fields.pop(field.name). If field.column is the same as field.name, then it has popped the value we just set.