Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: numeric primary key columns no longer coerce to serial4 #219

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions target_postgres/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ def create_empty_table(
property_name,
self.to_sql_type(property_jsonschema),
primary_key=is_primary_key,
autoincrement=False, # See: https://github.com/MeltanoLabs/target-postgres/issues/193 # noqa: E501
)
)
if as_temp_table:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{"type": "SCHEMA", "stream": "test_large_numeric_primary_key", "schema": {"properties": {"active": {"type": "boolean"}, "address1": {"type": ["string", "null"]}, "address2": {"type": ["string", "null"]}, "city": {"type": ["string", "null"]}, "country": {"type": ["string", "null"]}, "country_code": {"type": ["string", "null"]}, "created_at": {"type": ["string", "null"]}, "id": {"type": "number"}, "legacy": {"type": "boolean"}, "name": {"type": ["string", "null"]}, "phone": {"type": ["string", "null"]}, "province": {"type": ["string", "null"]}, "province_code": {"type": ["string", "null"]}, "updated_at": {"type": ["string", "null"]}, "zip": {"type": ["string", "null"]}, "localized_country_name": {"type": ["string", "null"]}, "localized_province_name": {"type": ["string", "null"]}}, "type": "object"}, "key_properties": ["id"]}
{"type": "RECORD", "stream": "test_large_numeric_primary_key", "record": {"id": 34639314995, "name": "111 Main St", "address1": "111 Main St", "address2": null, "city": "Sterling Heights", "zip": "48312", "province": "Michigan", "country": "US", "phone": "", "created_at": "2019-11-05T21:31:25-05:00", "updated_at": "2019-11-05T21:31:29-05:00", "country_code": "US", "province_code": "MI", "legacy": false, "active": true, "localized_country_name": "United States", "localized_province_name": "Michigan"}, "time_extracted": "2023-09-15T19:33:01.841018+00:00"}
10 changes: 10 additions & 0 deletions target_postgres/tests/test_standard_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,16 @@ def test_schema_no_properties(postgres_target):
singer_file_to_target(file_name, postgres_target)


# TODO test that data is correct
def test_large_numeric_primary_key(postgres_target):
"""Check that large numeric (jsonschema: number) pkeys don't cause failure.

See: https://github.com/MeltanoLabs/target-postgres/issues/193
"""
file_name = "large_numeric_primary_key.singer"
singer_file_to_target(file_name, postgres_target)


# TODO test that data is correct
def test_schema_updates(postgres_target):
file_name = "schema_updates.singer"
Expand Down
Loading