palewire / django-postgres-copy

Quickly import and export delimited data with Django support for PostgreSQL's COPY command
https://palewi.re/docs/django-postgres-copy/
MIT License
180 stars 48 forks source link

Added client encoding to adapted SQL parameters. #159

Open osvill opened 1 year ago

osvill commented 1 year ago

Fix & test for #158 .

palewire commented 1 year ago

This is an awesome start. Would it be possible to run a test that raises the encoding error so we can verify the reverse circumstance here?

osvill commented 1 year ago

It is hard to catch the error as a specific encoding error. I ended up adding a keyword argument client_encoding and raising a ValueError if client_encoding does not match the database encoding (2nd commit). What do you think?

osvill commented 1 year ago

I ran some more tests and got errors for adapted parameters that do not have the encoding attribute. Therefore I added the hasattr check and the test filtering by a number in the 3rd commit.