I had this code below:
self.db.execute("""
INSERT INTO gift_cards.transaction
(
gift_card_number, made_by_email, amount, is_refund,
payment_id, payment_type,
order_number, order_source,
reference, prism_reference
) VALUES (
?, ?, ?, ?,
?, ?,
?, ?,
?, ?
);
""", [
card_number, user_email or "UNKNOWN", processed_amount, is_refund,
validation_response["payment_id"], validation_response["payment_type"],
validation_response["order_number"], validation_response["order_source"],
reference, prism_reference
])
self.db.commit()
But the is_refund variable is a boolean, where the column in db is an integer.
Instead of throwing an error, it just silently failed and continued, leading to no transactions being saved.
This should definitely throw an error on column type mismatch. Not sure if it is being caught somewhere else that it doesn't bubble up.
I only noticed by accident when checking the database and it was empty.
This is what i did to fix it:
self.db.execute("""
INSERT INTO gift_cards.transaction
(
gift_card_number, made_by_email, amount, is_refund,
payment_id, payment_type,
order_number, order_source,
reference, prism_reference
) VALUES (
?, ?, ?, ?,
?, ?,
?, ?,
?, ?
);
""", [
card_number, user_email or "UNKNOWN", processed_amount, 1 if is_refund else 0,
validation_response["payment_id"], validation_response["payment_type"],
validation_response["order_number"], validation_response["order_source"],
reference, prism_reference
])
self.db.commit()
I had this code below:
But the
is_refundvariable is a boolean, where the column in db is an integer.Instead of throwing an error, it just silently failed and continued, leading to no transactions being saved.
This should definitely throw an error on column type mismatch. Not sure if it is being caught somewhere else that it doesn't bubble up.
I only noticed by accident when checking the database and it was empty.
This is what i did to fix it: