piccolo-orm/piccolo

`ModelBuilder` and recursive foreign keys

Closed this issue · 0 comments

If you have a foreign key which references its own table:

class MyTable(Table):
    fk = ForeignKey("self")

You get an error when using ModelBuilder:

>>> await ModelBuilder.build(MyTable)
Max recursion error!

If the foreign key is nullable, we can set the value to None, to avoid an infinite loop.