Skip to content

Commit

Permalink
[target-postgres] fix: Map date column to correct postgres type (#1188)
Browse files Browse the repository at this point in the history
  • Loading branch information
danilofuchs authored Nov 5, 2024
1 parent 81f607f commit 4895d9f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions singer-connectors/target-postgres/target_postgres/db_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def column_type(schema_property):
# TIMESTAMP WITH TIME ZONE is the better column type
elif property_format == 'date-time':
col_type = 'timestamp without time zone'
elif property_format == 'date':
col_type = 'date'
elif property_format == 'time':
col_type = 'time without time zone'
elif 'number' in property_type:
Expand Down
4 changes: 4 additions & 0 deletions singer-connectors/target-postgres/tests/unit/test_db_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ def test_column_type_mapping(self):
json_str_or_null = {"type": ["string", "null"] }
json_dt = {"type": ["string"] , "format": "date-time"}
json_dt_or_null = {"type": ["string", "null"] , "format": "date-time"}
json_date = {"type": ["string"] , "format": "date"}
json_date_or_null = {"type": ["string", "null"] , "format": "date"}
json_t = {"type": ["string"] , "format": "time"}
json_t_or_null = {"type": ["string", "null"] , "format": "time"}
json_num = {"type": ["number"] }
Expand All @@ -75,6 +77,8 @@ def test_column_type_mapping(self):
self.assertEqual(mapper(json_str_or_null) , 'character varying')
self.assertEqual(mapper(json_dt) , 'timestamp without time zone')
self.assertEqual(mapper(json_dt_or_null) , 'timestamp without time zone')
self.assertEqual(mapper(json_date) , 'date')
self.assertEqual(mapper(json_date_or_null) , 'date')
self.assertEqual(mapper(json_t) , 'time without time zone')
self.assertEqual(mapper(json_t_or_null) , 'time without time zone')
self.assertEqual(mapper(json_num) , 'double precision')
Expand Down

0 comments on commit 4895d9f

Please sign in to comment.