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")
|
shopping_events = relationship("ShoppingEvent", secondary=shopping_event_products, back_populates="products")
|
||||||
|
|
||||||
# Self-referential many-to-many relationship for related 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(
|
related_products = relationship(
|
||||||
"Product",
|
"Product",
|
||||||
secondary=related_products,
|
secondary=related_products,
|
||||||
primaryjoin=id == related_products.c.product_id,
|
primaryjoin="Product.id == related_products.c.product_id",
|
||||||
secondaryjoin=id == related_products.c.related_product_id,
|
secondaryjoin="Product.id == related_products.c.related_product_id",
|
||||||
back_populates="related_to_products"
|
viewonly=True
|
||||||
)
|
|
||||||
|
|
||||||
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"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
class Shop(Base):
|
class Shop(Base):
|
||||||
|
|||||||
@ -173,6 +173,7 @@ class ShopStats(BaseModel):
|
|||||||
|
|
||||||
# Update forward references
|
# Update forward references
|
||||||
BrandInShop.model_rebuild()
|
BrandInShop.model_rebuild()
|
||||||
|
ProductWithRelated.model_rebuild()
|
||||||
|
|
||||||
# Related Products schemas
|
# Related Products schemas
|
||||||
class RelatedProductBase(BaseModel):
|
class RelatedProductBase(BaseModel):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user