When i give a parameter(ex: 1 )The query is intended to retrieve data from CustomModelSerielPort where CustomModelSerielPort.gateway_id (ex:1)_matches Gateway.id (ex:1), and the data is only returned if Gateway.is_partner_ipc is equal to 1.
def list_serial_port(gateway_id: int, db: Session):
result = {"item_list": []}
serial_ports = (
db.query(CustomModelSerielPort.id, CustomModelSerielPort.path)
.join(Gateway, CustomModelSerielPort.gateway_id == Gateway.id)
.filter(Gateway.id == gateway_id)
.filter(Gateway.is_partner_ipc == 1)
.all()
)
If i give a parameter(ex: 3), i shouldn't get any data because Gateway.is_partner_ipc ==0,
However i still can get data, just like filter doesn't work, and if i change my condition to
.filter(Gateway.is_partner_ipc == 0)
I expect to get data when give a parameter(ex: 3) but no data when give a parameter(ex: 1 ), however both wont get any data, do anyone now what wrong with my code, thank a lot.
0 comments:
Post a Comment
Thanks