Closed willow-yang closed 4 weeks ago
What is happening is when you are selecting the Student.teacher_id
and Teacher.name
only, Peewee is creating two models for each row in the database: a Student and it's associated Teacher instance. When it applies the Teacher instance to the Student, the Teacher "id" was not selected explicitly and is None. When setting the Student.teacher attribute (which has an empty primary-key), this in turn sets the Student.teacher_id to None. This is a sort-of a bug, but the workarounds are easy:
.objects()
to flatten the data.thanks!
When joining two tables using a foreign key, the query result for the foreign key field does not meet expectations.
the output is