Skip to content

Commit

Permalink
Fix postgres handling for unlimited varchars (dbt-labs#5292)
Browse files Browse the repository at this point in the history
* 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 <ebuschang@gmail.com>

Co-authored-by: Emily Rockman <ebuschang@gmail.com>
  • Loading branch information
2 people authored and Axel Goblet committed Sep 16, 2022
1 parent d2cc705 commit be6ee92
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .changes/unreleased/Fixes-20220523-103843.yaml
Original file line number Diff line number Diff line change
@@ -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"
6 changes: 4 additions & 2 deletions plugins/postgres/dbt/adapters/postgres/relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit be6ee92

Please sign in to comment.