Skip to content

tests: Handle DDL command in cur.sql() differently #785

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

Merged
merged 1 commit into from
May 12, 2025

Conversation

JelteF
Copy link
Collaborator

@JelteF JelteF commented May 12, 2025

For ease of programming we have a cur.sql() method that can be used to execute any sql command. Fetching rows for DDL statements doesn't work though, so we were catching that error and ignoring it. In psycopg 3.2.8 the exact error message was changed.

Instead of detecting the new error message, this change makes sure that we don't trigger this error at all. This is done by detecting whether our result has rows, before calling fetchall().

Originally reported @Alphaxxxxx in #784 (comment)

For ease of programming we have a `cur.sql()` method that can be used to
execute any sql command. Fetching rows for DDL statements doesn't work
though, so we were catching that error and ignoring it. In psycopg 3.2.8
the exact error message was changed.

Instead of detecting the new error message, this instead makes sure that
we don't get this error at all. This is done by detecting whether our
result has rows, before calling `fetchall()`.
@JelteF JelteF enabled auto-merge (squash) May 12, 2025 09:40
@JelteF JelteF requested a review from Y-- May 12, 2025 09:40
@Y--
Copy link
Collaborator

Y-- commented May 12, 2025

Ah I was just working on this :-) Thnaks!

@JelteF JelteF merged commit 5e77073 into main May 12, 2025
6 checks passed
@JelteF JelteF deleted the fix-test-for-pytest-3.2.8 branch May 12, 2025 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants