我有两个要查询的Sqlalchemy模型。
一个是Order(),另一个是Purchase()。
但是,当我查询Order()以获取所有元素时,它可以按预期工作,但是与Purchasei一起获得以下sqlalchemy.exc.InvalidRequestError:预期的SQL表达式,列或映射的实体-得到了'
为了进一步挖掘,我打印了我得到的模型的类型。当我打印(类型(订购)时,我得到的类型与另一张打印(类型(购买)时得到的我的类型)。
这些是我的模特:
顺序:(我只是在这里粘贴模型的一部分,因为它有很多列)
class Order(BaseModel):
__tablename__ = 'Order'
__table_args__ = {'schema': 'mySchema'}
orderId = Column("OrderId",Integer, primary_key=True, server_default=text(
"nextval('\"mySchema\".\"Order_OrderId_seq\"'::regclass)"),supports_dict=True,
on_serialize=None,
on_deserialize=None,)
orderTypeId = Column("OrderTypeId",Integer,ForeignKey(mySchema.OrderType.OrderTypeId'), nullable=False,supports_dict=True,
on_serialize=None,
on_deserialize=None,)
orderCreationTypeId = Column("OrderCreationTypeId",
ForeignKey('mySchema.OrderCreationType.OrderCreationTypeId',
ondelete='CASCADE', onupdate='CASCADE'), nullable=False,supports_dict=True,
on_serialize=None,
on_deserialize=None,)
}
购买:
购买类别(BaseModel):
__tablename__ = 'Purchase'
__table_args__ = {'schema': 'mySchema'}
PurchaseId= Column(Integer, primary_key=True, server_default=text("nextval('\"mySchema\".\"purchase_seq\"'::regclass)"),supports_dict=True,
on_serialize=None,
on_deserialize=None,)
OrderId = Column(ForeignKey('mySchema.Order.OrderId'), nullable=False,supports_dict=True,
on_serialize=None,
on_deserialize=None,)
OrderNumber= Column(String(10), nullable=False,supports_dict=True,
on_serialize=None,
on_deserialize=None,)
WaitTime= Column(Integer,supports_dict=True,
on_serialize=None,
on_deserialize=None,)
StoreWaitTime= Column(Integer,supports_dict=True,
on_serialize=None,
on_deserialize=None,)
}
请让我知道我错了。这里真的很糟糕。