Yes, absolutely!
Simplifying the use, I basically have 2 models: ItemDesign and ItemSet, where an ItemDesign can have multiple item sets. ItemDesign have a lot of other FK relationships that works without a hitch. I'm using sqlite 3.22.
The code I run is a simple select query, where I want to preload data for the ItemDesign classes. Removing all other prefetch querying, the minimal example bugging is this:
prefetch(ItemDesign.select(), ItemSet.select())
The classes looks like this:
from playhouse.flask_utils import FlaskDB
database = FlaskDB()
class BaseModel(database.Model):
class Meta:
legacy_table_names = False
class BaseUUIDModel(BaseModel):
id = UUIDField(primary_key=True, default=uuid.uuid4)
----
from peewee import CharField, TextField, ForeignKeyField, IntegerField
from playhouse.sqlite_ext import JSONField
class ItemDesign(BaseUUIDModel):
name = CharField()
rarity = CharField(choices=Rarity.choices_list(), default=Rarity.Normal)
stats = JSONField()
vanity_text = TextField(null=True)
icon = ForeignKeyField(Icon, backref='item_uses')
item_set = ForeignKeyField(ItemSet, backref='items', null=True, on_delete='SET NULL')
item_slot = IntegerField(choices=ItemSlot.choices_list())
item_type = ForeignKeyField(ItemType, backref='items', on_delete='SET NULL')
----
from peewee import CharField, TextField
class ItemSet(BaseUUIDModel):
name = CharField(unique=True)
vanity_text = TextField(null=True)