fix db errror
This commit is contained in:
parent
112ea41e88
commit
666ce5d4d4
@ -83,20 +83,13 @@ class Product(Base):
|
||||
shopping_events = relationship("ShoppingEvent", secondary=shopping_event_products, back_populates="products")
|
||||
|
||||
# Self-referential many-to-many relationship for related products
|
||||
# We'll use a simpler approach without back_populates to avoid circular references
|
||||
related_products = relationship(
|
||||
"Product",
|
||||
secondary=related_products,
|
||||
primaryjoin=id == related_products.c.product_id,
|
||||
secondaryjoin=id == related_products.c.related_product_id,
|
||||
back_populates="related_to_products"
|
||||
)
|
||||
|
||||
related_to_products = relationship(
|
||||
"Product",
|
||||
secondary=related_products,
|
||||
primaryjoin=id == related_products.c.related_product_id,
|
||||
secondaryjoin=id == related_products.c.product_id,
|
||||
back_populates="related_products"
|
||||
primaryjoin="Product.id == related_products.c.product_id",
|
||||
secondaryjoin="Product.id == related_products.c.related_product_id",
|
||||
viewonly=True
|
||||
)
|
||||
|
||||
class Shop(Base):
|
||||
|
||||
@ -173,6 +173,7 @@ class ShopStats(BaseModel):
|
||||
|
||||
# Update forward references
|
||||
BrandInShop.model_rebuild()
|
||||
ProductWithRelated.model_rebuild()
|
||||
|
||||
# Related Products schemas
|
||||
class RelatedProductBase(BaseModel):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user