Skip to content

Add identifier filter to support dynamic and safe insertion of identifiers#33

Open
tomasfarias wants to merge 12 commits into
sripathikrishnan:masterfrom
tomasfarias:add-identifier-filter
Open

Add identifier filter to support dynamic and safe insertion of identifiers#33
tomasfarias wants to merge 12 commits into
sripathikrishnan:masterfrom
tomasfarias:add-identifier-filter

Conversation

@tomasfarias
Copy link
Copy Markdown

This PR adds an identifier filter to escape SQL identifiers, like table and field names. As mentioned in #32, this would allow for safe and dynamic insertion of table and field names. Currently, this is possible via the sqlsafe filter but we delegate the responsibility of escaping strings to the user.

The implementation will depend on database engine, which is why a new db_engine parameter was added. I've implemented the filter for escaping strings in Postgres, although I would be willing to include more alternatives in this PR if that's needed to be considered complete.

On invalid (not implemented or non-existent) engines, a ValueError is raised. Should I use instead a new exception inheriting from JinjaSqlException?

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