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

Context tracking causes issues with SQL that has % and no arguments #149

Open
wesleykendall opened this issue Sep 2, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@wesleykendall
Copy link
Member

Recent changes to pghistory's context tracking ensures %s is used when rendering SQL to inject variables.

This, however, causes issues for SQL with % that doesn't have any arguments. For example, pghistory's context tracking function:

CREATE OR REPLACE FUNCTION _pgh_attach_context()
                RETURNS {cls._meta.db_table}.id%TYPE AS $$
                    DECLARE
...

It's likely best we solve this by using mogrify to render the SQL instead of passing down arguments as %s to Psycopg. This would likely simplify codepaths that have to account for positional/kwarg variable syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant