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

Account for sql.SQL and sql.Composed Objects #177

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

max-muoto
Copy link
Contributor

@max-muoto max-muoto commented Sep 29, 2024

Support sql.SQL and sql.Composed objects, which are valid ways to execute SQL within Psycopg 3.

(b"select count(*) from auth_user", ()),
("select count(*) from auth_user where id = %s", (1,), 2),
("select count(*) from auth_user", (), 2),
(b"select count(*) from auth_user where id = %s", (1,), 2),
Copy link
Contributor Author

@max-muoto max-muoto Sep 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense to run these on 3 as the query can still technically be bytes. See https://github.com/psycopg/psycopg/blob/master/psycopg/psycopg/abc.py#L30

from unittest.mock import MagicMock

SQL = MagicMock()
Literal = MagicMock()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to avoid the parameterization failing on 3.

@max-muoto max-muoto marked this pull request as ready for review September 29, 2024 22:26
@max-muoto max-muoto marked this pull request as draft September 29, 2024 22:49
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.

1 participant