From be6ee9291bdce25270c6eaab5c9dfdefaaf2e662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9on=20Stefani?= Date: Tue, 9 Aug 2022 16:59:58 +0200 Subject: [PATCH] Fix postgres handling for unlimited varchars (#5292) * Fix postgres handling for unlimited varchars * fix: correctly name varchar * chore: added changelog entry * Update .changes/unreleased/Fixes-20220523-103843.yaml Co-authored-by: Emily Rockman Co-authored-by: Emily Rockman --- .changes/unreleased/Fixes-20220523-103843.yaml | 8 ++++++++ plugins/postgres/dbt/adapters/postgres/relation.py | 6 ++++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 .changes/unreleased/Fixes-20220523-103843.yaml diff --git a/.changes/unreleased/Fixes-20220523-103843.yaml b/.changes/unreleased/Fixes-20220523-103843.yaml new file mode 100644 index 00000000000..15a2342d7d8 --- /dev/null +++ b/.changes/unreleased/Fixes-20220523-103843.yaml @@ -0,0 +1,8 @@ +kind: Fixes +body: Remove the default 256 characters limit on postgres character varying type when + no limitation is set +time: 2022-05-23T10:38:43.392232+02:00 +custom: + Author: shrodingers + Issue: "5238" + PR: "5292" diff --git a/plugins/postgres/dbt/adapters/postgres/relation.py b/plugins/postgres/dbt/adapters/postgres/relation.py index 517984c281a..0f3296c1818 100644 --- a/plugins/postgres/dbt/adapters/postgres/relation.py +++ b/plugins/postgres/dbt/adapters/postgres/relation.py @@ -26,7 +26,9 @@ def relation_max_name_length(self): class PostgresColumn(Column): @property def data_type(self): - # on postgres, do not convert 'text' to 'varchar()' - if self.dtype.lower() == "text": + # on postgres, do not convert 'text' or 'varchar' to 'varchar()' + if self.dtype.lower() == "text" or ( + self.dtype.lower() == "character varying" and self.char_size is None + ): return self.dtype return super().data_type