mirror of
https://github.com/datahub-project/datahub.git
synced 2025-09-01 13:23:09 +00:00
fix(ingest/salesforce): escape markdown char for multiline description (#10351)
This commit is contained in:
parent
934ab03d16
commit
b9a34fe90b
@ -537,11 +537,21 @@ class SalesforceSource(Source):
|
|||||||
|
|
||||||
# Here field description is created from label, description and inlineHelpText
|
# Here field description is created from label, description and inlineHelpText
|
||||||
def _get_field_description(self, field: dict, customField: dict) -> str:
|
def _get_field_description(self, field: dict, customField: dict) -> str:
|
||||||
desc = field["Label"]
|
desc = (
|
||||||
if field.get("FieldDefinition", {}).get("Description"):
|
"\\" + field["Label"] if field["Label"].startswith("#") else field["Label"]
|
||||||
desc = "{0}\n\n{1}".format(desc, field["FieldDefinition"]["Description"])
|
)
|
||||||
if field.get("InlineHelpText"):
|
|
||||||
desc = "{0}\n\n{1}".format(desc, field["InlineHelpText"])
|
for key in ["FieldDefinition", "InlineHelpText"]:
|
||||||
|
text: Optional[str] = ""
|
||||||
|
if isinstance(field.get(key), dict):
|
||||||
|
text = field[key].get("Description")
|
||||||
|
else:
|
||||||
|
text = field.get(key)
|
||||||
|
|
||||||
|
if text:
|
||||||
|
prefix = "\\" if text.startswith("#") else ""
|
||||||
|
desc += f"\n\n{prefix}{text}"
|
||||||
|
|
||||||
return desc
|
return desc
|
||||||
|
|
||||||
# Here jsonProps is used to add additional salesforce field level properties.
|
# Here jsonProps is used to add additional salesforce field level properties.
|
||||||
@ -575,13 +585,6 @@ class SalesforceSource(Source):
|
|||||||
|
|
||||||
description = self._get_field_description(field, customField)
|
description = self._get_field_description(field, customField)
|
||||||
|
|
||||||
# escaping string starting with `#`
|
|
||||||
description = (
|
|
||||||
"\\" + description
|
|
||||||
if description and description.startswith("#")
|
|
||||||
else description
|
|
||||||
)
|
|
||||||
|
|
||||||
schemaField = SchemaFieldClass(
|
schemaField = SchemaFieldClass(
|
||||||
fieldPath=fieldPath,
|
fieldPath=fieldPath,
|
||||||
type=SchemaFieldDataTypeClass(type=TypeClass()), # type:ignore
|
type=SchemaFieldDataTypeClass(type=TypeClass()), # type:ignore
|
||||||
|
@ -2517,6 +2517,7 @@
|
|||||||
"QualifiedApiName": "Unique_Account",
|
"QualifiedApiName": "Unique_Account",
|
||||||
"DeveloperName": "Unique_Account",
|
"DeveloperName": "Unique_Account",
|
||||||
"Label": "# Unique_Account",
|
"Label": "# Unique_Account",
|
||||||
|
"InlineHelpText": "# Help Text",
|
||||||
"FieldDefinition": {
|
"FieldDefinition": {
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"type": "FieldDefinition",
|
"type": "FieldDefinition",
|
||||||
@ -2527,7 +2528,8 @@
|
|||||||
"LastModifiedBy": null,
|
"LastModifiedBy": null,
|
||||||
"IsIndexed": false,
|
"IsIndexed": false,
|
||||||
"ComplianceGroup": null,
|
"ComplianceGroup": null,
|
||||||
"SecurityClassification": null
|
"SecurityClassification": null,
|
||||||
|
"Description": "This is the # description"
|
||||||
},
|
},
|
||||||
"DataType": "string",
|
"DataType": "string",
|
||||||
"Precision": 0,
|
"Precision": 0,
|
||||||
|
@ -1354,7 +1354,7 @@
|
|||||||
{
|
{
|
||||||
"fieldPath": "Unique_Account",
|
"fieldPath": "Unique_Account",
|
||||||
"nullable": true,
|
"nullable": true,
|
||||||
"description": "\\# Unique_Account",
|
"description": "\\# Unique_Account\n\nThis is the # description\n\n\\# Help Text",
|
||||||
"type": {
|
"type": {
|
||||||
"type": {
|
"type": {
|
||||||
"com.linkedin.schema.StringType": {}
|
"com.linkedin.schema.StringType": {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user