Support for VARCHAR with no size restriction
Closed this issue · 1 comments
Hi, thanks for this great resource!
I have tables with several VARCHAR fields with no size restriction. As I understand this is a Postgres-specific extension that allows the fields to act like TEXT under the hood.
When using pgcopy, I found that the values inserted into these fields were getting truncated (which showed up as a violated uniqueness constraint). Looking into the code, I saw that what was happening was that the inspect.get_types() function was returning -1 for the attypmod, which was getting passed to the maxsize_formatter as the length, and subsequently stripping off the last character in every value. Obviously, I could change the definition of these fields to TEXT (and I still may) but I thought that pgcopy should probably support these types of fields. Will file a simple PR shortly.
This fix is released in version 1.3.0 on pypi now. Thanks again for your contribution!