Peewee+PSQL: create_tables for complex object relationships broken when DeferredRelations in play
See original GitHub issueAs in the docs, circular FK dependencies are a code smell, and I agree, but here we are. I’ve got a big object domain with some of these objects having circular foreign keys.
In peewee
versions in the 2.8 line, create_tables
seemed to be able to resolve any DeferredRelation
s used for circular FK relationships and tell PSQL to create the tables appropriately. I see in the docs that there’s a more manual approach documented, but I’ve never encountered need for it until upgrading from 2.8.x to 2.10.x.
Two questions:
- Am I correct in finding that the behavior of automatically doing this was done by
peewee
prior, and is now no longer supported? (otherwise, what magic could it have been that made this work before?) - Do you have any recommended methods for enabling a more opinionated methodology to creating tables in this way, or automating the process as documented? My CI environment does a build/teardown of tables every run (sometimes every test) and I’m thinking that having a special codepath for each
DeferredRelation
’s setup is a little unclean.
I know it’s a way uncommon use-case (and a noncurrent version on top of that), but I’m hoping you might have some top-of-the-head insight as to what in particular changed; the changelog between the versions don’t really show anything that appears related.
As always, thanks for your continued work and support on this tool – it’s a wonderful piece of tech.
Issue Analytics
- State:
- Created 6 years ago
- Comments:14 (14 by maintainers)
Top GitHub Comments
Hmm… it looks like changes to the way deferred foreign-keys were resolved, although there are quite a few changes so I’m not positive.
At any rate, I don’t think there’s a whole lot I can offer, as Peewee is now at 3.x and any fixes would pertain to how the code functions in 3.x (which is somewhat different from 2.10). Sorry not to be of more help.
I appreciate your help with the investigation. I’m looking to get to 3.x eventually, but wanted to understand what was going wrong here before I opened that can of worms.