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 extract_signature to work with sql.Composable objects #148

Closed

Conversation

beniwohli
Copy link
Contributor

@beniwohli beniwohli force-pushed the pyscopg2-composable-fixes branch 3 times, most recently from 60972bf to 2260ac6 Compare January 29, 2018 14:24
"""
Method to turn the "sql" argument into a string
"""
return sql
Copy link
Contributor

Choose a reason for hiding this comment

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

The method description might be a bit confusing, as it actually does nothing in this class.
Would it do any harm if you'd actually move the as_string check here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the as_string check is specific to psycopg2 (the Python PostgreSQL driver), so I think putting it in the psycopg2-specific subclass makes sense. However I agree that the docstring needs work.

@@ -121,6 +121,11 @@ def scan(tokens):


def extract_signature(sql):
Copy link
Contributor

Choose a reason for hiding this comment

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

Not part of this PR, but out of interest, why is this not a method of CursorProxy ? Afaics this is only used within sql cursor proxy implementations.

Copy link
Contributor Author

@beniwohli beniwohli Jan 30, 2018

Choose a reason for hiding this comment

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

I thought about this as well, but into the other direction: remove CursorProxy.extract_signature and call dbapi2.extract_signature() directly where we need it.

I guess the idea was that if we instrument a SQL backend that needs a different parser, we could plug it in there. @roncohen might remember.

In any case, I'll leave this for another PR :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for giving some context. Might be worth giving it a thought at some point, but as mentioned unrelated to this PR.

@beniwohli beniwohli closed this in ff43877 Jan 30, 2018
@beniwohli beniwohli deleted the pyscopg2-composable-fixes branch January 30, 2018 09:05
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.

None yet

2 participants