server-client-python
server-client-python copied to clipboard
Filter Operator.In - Cannot find groups/projects with spaces in their name
Description
Calling groups.get
endpoint I'm unable to filter using the Operator.In
operator.
Versions
- Tableau Server version: 2021.1.0 (20211.21.0430.0040) 64-bit Linux
- Python version: Python 3.7.7
- TSC library version: tableauserverclient==0.15.0
To Reproduce
req_options = RequestOptions()
req_options.filter.add(Filter(RequestOptions.Field.Name, RequestOptions.Operator.In, ["Group A", "Group B"]))
groups, pagination = server.groups.get(req_options=req_options)
for group in groups:
logger.info(group)
Results
<tableauserverclient.models.group_item.GroupItem object at 0x42>
Expected Results
<tableauserverclient.models.group_item.GroupItem object at 0x42>
<tableauserverclient.models.group_item.GroupItem object at 0x43>
Thank you! We are tracking this internally. Will get back to you as soon as we have an update.
ID: 1278983
@jesusenlanet In your example, you use RequestOptions.Operator.Equals
did you mean to use RequestOptions.Operator.In
? Using In with groups works as expected for me.
Hey @jorwoods
Oh, sorry for the Equals
, I mean In
, I think I make some error writing the comment, here the script I'm using:
req_options = TSC.RequestOptions()
req_options.filter.add(TSC.Filter(TSC.RequestOptions.Field.Name, TSC.RequestOptions.Operator.In, ["Group A", "Group B"]))
groups, pagination_item = server.groups.get(req_options)
for group in groups:
print(group.__dict__)
What I'm obtaining is confusing, it looks that if a group is using a View
template on the privileges, it doesn't appear on the list.
Groups like that are not appearing on the results.
Do these groups also appear in the groups section of the site? Are you a site/server admin?
Do these groups also appear in the groups section of the site? Are you a site/server admin?
Yes, I am an admin and those groups appear on the project permission list.
I tried to retrieve groups for another projects and I'm unable to obtain some of the groups using the Publish
template. I can't identify a pattern at this moment.
Not within the permissions list, but within the actual "Groups" section of the overall site.
Not within the permissions list, but within the actual "Groups" section of the overall site.
Yes, they appear in the main groups list, some of them appear on the response, some other no.
Also all of them have the same local
domain.
In theory this was fixed a long while ago, but it's not working now. Same problem with searching In for projects. I suspect fixes we made for other encoding issues broke this one again.
I think the same issue affects workbooks. Working on a sample with Superstore and World Indicators and not returning anything with In. 😢
I have the exact same issue when querying for data sources. I have one that has a space in the name and it just removes the space and does not url encode it at all. So I don't get a match.
The example datasource is "EoA Datasource - Pol"
and when I debug the urllib3
output for the rest call is the following
https://server/api/3.15/sites/site_id/datasources?pageNumber=1&pageSize=50$filter=name%3Ain%3A%5BMD1700%2CEoADatasource-Pol%5D
I face the same issue: when searching for projects, spaces in the search term are removed by this line 14
in tableauserverclient/server/filter.py
def __str__(self):
value_string = str(self._value)
if isinstance(self._value, list):
value_string = value_string.replace(" ", "").replace("'", "") <---
return "{0}:{1}:{2}".format(self.field, self.operator, value_string)
This really should be parsed into URL encoding instead of just removing spaces and single quotes
urllib.parse.quote (value_string)
should do the trick here.
Or, simpler, value_string.replace (" ", "%20").replace("'", "")
The last change to this line did not change this behavior.
I do not see how enabling search terms with spaces requires a server side enhancement. When searching from the UI both Tableau Server and Cloud encode the space in the search term with %20
and return the correct result.
I've committed PR #1259 to fix this issue.