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

Hash produces errors on strings with backslashes in Postgres #14

Open
Matt343 opened this issue Oct 11, 2024 · 0 comments
Open

Hash produces errors on strings with backslashes in Postgres #14

Matt343 opened this issue Oct 11, 2024 · 0 comments

Comments

@Matt343
Copy link

Matt343 commented Oct 11, 2024

Using {{ dbt_privacy.hash('my_field', salt_expr = 'my_salt') }} fails if the my_field or my_salt columns contain text with single backslashes in them. Postgres throws Postgres adapter: Postgres error: invalid input syntax for type bytea, because the macro tries to convert to bytea using a my_salt::varchar::bytea expression, which expects a string that can contain escapes. The value \xfoobar is an example of an invalid escape sequence that could be in the string, that will throw an error on this cast to bytea. The safe way to convert text to binary in postgres is something like convert_to(my_salt, pg_client_encoding()), which will handle escapes properly.

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

No branches or pull requests

1 participant