Skip to content

Don't use 'literal_binds' in executed SQL — it's a debugging option - #9505

Open
bluepython508 wants to merge 3 commits into
ckan:masterfrom
bluepython508:bluepython508/literal-binds
Open

bluepython508 wants to merge 3 commits into
ckan:masterfrom
bluepython508:bluepython508/literal-binds

Conversation

@bluepython508

Copy link
Copy Markdown
Contributor

literal_binds is documented as generally being for logging or debugging purposes, and the result shouldn't be passed to databases.

We can use psycopg2's provided mechanism to do this.

@wardi wardi self-assigned this Aug 27, 2026

@caiotheodoro caiotheodoro left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

File doesn't parse as-is (indentation is broken from inline_sql_parameters onward), which is why 19/21 checks are failing. One design concern once that's fixed, inline.

Comment thread ckanext/datastore/backend/postgres.py Outdated
return len(pglast.parser.parse_sql(sql)) == 1
except pglast.parser.ParseError:
return False
def inline_sql_parameters(sql: str, params: dict) -> str:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

bug: mixed leading whitespace from here through is_single_statement - ruff reports invalid-syntax: unindent does not match any outer indentation level starting at this line. This is the whole reason Ruff/PyRight/pytest/Cypress are all red, not a real regression in the approach.

if not is_single_statement(sql_string, params):
clause = inline_sql_parameters(sql_string, params)

if not is_single_statement(clause):

This comment was marked as duplicate.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants