Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix error when cursor.lastrowid doesnt exist #281

Merged
merged 1 commit into from
May 25, 2023

Conversation

JamieDanielson
Copy link
Contributor

Which problem is this PR solving?

Short description of the changes

  • only add db.last_insert_id if lastrowid exists on the Cursor object.

A similar fix is already in place for Flask middleware. When using psycopg2, the lastrowid existed but came through as 0. When using psycopg3, the lastrowid doesn't exist, which caused an exception.

The below screenshot shows a before and after for this fix.

before-and-after-lastrowid-fix

@JamieDanielson JamieDanielson requested a review from a team May 24, 2023 19:45
@JamieDanielson JamieDanielson self-assigned this May 24, 2023
@JamieDanielson JamieDanielson added status: oncall Flagged for awareness from Honeycomb Telemetry Oncall type: bug Something isn't working version: bump patch A PR with release-worthy changes and is backwards-compatible. labels May 24, 2023
@JamieDanielson JamieDanielson merged commit 2bf2fb3 into main May 25, 2023
@JamieDanielson JamieDanielson deleted the jamie.lastrowid branch May 25, 2023 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: oncall Flagged for awareness from Honeycomb Telemetry Oncall type: bug Something isn't working version: bump patch A PR with release-worthy changes and is backwards-compatible.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'Cursor' object has no attribute 'lastrowid'
2 participants