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

Location types can also be JSON objects #36

Merged
merged 1 commit into from
Feb 7, 2018
Merged
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
11 changes: 8 additions & 3 deletions tap_salesforce/salesforce/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,18 @@ def field_to_property_schema(field, mdata):
mdata = metadata.write(mdata, ('properties', field_name),
"unsupported-description", "binary data")
return property_schema, mdata
elif sf_type == 'location': # geo coordinates are divided into two fields for lat/long
property_schema['type'] = "number"
elif sf_type == 'location':
# geo coordinates are numbers or objects divided into two fields for lat/long
property_schema['type'] = ["number", "object", "null"]
property_schema['properties'] = {
"longitude": {"type": ["null", "number"]},
"latitude": {"type": ["null", "number"]}
}
else:
raise TapSalesforceException("Found unsupported type: {}".format(sf_type))

# The nillable field cannot be trusted
if field_name != 'Id':
if field_name != 'Id' and sf_type != 'location':
property_schema['type'] = ["null", property_schema['type']]

return property_schema, mdata
Expand Down