server-client-python icon indicating copy to clipboard operation
server-client-python copied to clipboard

Filter Operator.In - Cannot find groups/projects with spaces in their name

Open jesusenlanet opened this issue 3 years ago • 12 comments

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>

jesusenlanet avatar May 12 '21 16:05 jesusenlanet

Thank you! We are tracking this internally. Will get back to you as soon as we have an update.

ID: 1278983

ovinis avatar Jun 14 '21 22:06 ovinis

@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.

jorwoods avatar Aug 31 '21 20:08 jorwoods

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. Captura de pantalla 2021-09-01 a las 11 10 27

Groups like that are not appearing on the results.

jesusenlanet avatar Sep 01 '21 09:09 jesusenlanet

Do these groups also appear in the groups section of the site? Are you a site/server admin?

jorwoods avatar Sep 01 '21 11:09 jorwoods

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.

jesusenlanet avatar Sep 01 '21 16:09 jesusenlanet

Not within the permissions list, but within the actual "Groups" section of the overall site.

jorwoods avatar Sep 01 '21 16:09 jorwoods

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.

jesusenlanet avatar Sep 01 '21 17:09 jesusenlanet

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.

jacalata avatar Feb 16 '23 22:02 jacalata

I think the same issue affects workbooks. Working on a sample with Superstore and World Indicators and not returning anything with In. 😢

bryceglarsen avatar Mar 25 '23 23:03 bryceglarsen

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

bab014 avatar Apr 24 '23 20:04 bab014

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.

LarsBreddemann avatar Jul 10 '23 04:07 LarsBreddemann

I've committed PR #1259 to fix this issue.

LarsBreddemann avatar Jul 25 '23 05:07 LarsBreddemann