Skip to content

Commit

Permalink
Do not create empty connections list (#1178)
Browse files Browse the repository at this point in the history
This should fix (1) from #1139 (comment), by preventing us from sending an empty connections element if the list of connections is empty.
jacalata authored Feb 14, 2023

Verified

This commit was signed with the committer’s verified signature. The key has expired.
nikolaybotev Nikolay Botev
1 parent 47eab0b commit 06e33fa
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tableauserverclient/server/request_factory.py
Original file line number Diff line number Diff line change
@@ -182,10 +182,10 @@ def _generate_xml(self, datasource_item, connection_credentials=None, connection
if connection_credentials is not None and connections is not None:
raise RuntimeError("You cannot set both `connections` and `connection_credentials`")

if connection_credentials is not None:
if connection_credentials is not None and connection_credentials != False:
_add_credentials_element(datasource_element, connection_credentials)

if connections is not None and len(connections) > 0:
if connections is not None and connections != False and len(connections) > 0:
connections_element = ET.SubElement(datasource_element, "connections")
for connection in connections:
_add_connections_element(connections_element, connection)
@@ -337,7 +337,7 @@ def _generate_xml(self, flow_item: "FlowItem", connections: Optional[List["Conne
project_element = ET.SubElement(flow_element, "project")
project_element.attrib["id"] = flow_item.project_id

if connections is not None:
if connections is not None and connections != False:
connections_element = ET.SubElement(flow_element, "connections")
for connection in connections:
_add_connections_element(connections_element, connection)
@@ -904,10 +904,10 @@ def _generate_xml(
if connection_credentials is not None and connections is not None:
raise RuntimeError("You cannot set both `connections` and `connection_credentials`")

if connection_credentials is not None:
if connection_credentials is not None and connection_credentials != False:
_add_credentials_element(workbook_element, connection_credentials)

if connections is not None and len(connections) > 0:
if connections is not None and connections != False and len(connections) > 0:
connections_element = ET.SubElement(workbook_element, "connections")
for connection in connections:
_add_connections_element(connections_element, connection)

0 comments on commit 06e33fa

Please sign in to comment.