Skip to content

fix: put special fields first #1622

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

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion tableauserverclient/server/request_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ def get_query_params(self) -> dict:
if self.pagesize:
params["pageSize"] = self.pagesize
if self.fields:
params["fields"] = ",".join(self.fields)
if "_all_" in self.fields:
params["fields"] = "_all_"
else:
params["fields"] = ",".join(sorted(self.fields))
return params

def page_size(self, page_size):
Expand Down
24 changes: 24 additions & 0 deletions test/test_request_option.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,3 +378,27 @@ def test_queryset_only_fields(self) -> None:
loop = self.server.users.only_fields("id")
assert "id" in loop.request_options.fields
assert "_default_" not in loop.request_options.fields

def test_queryset_field_order(self) -> None:
with requests_mock.mock() as m:
m.get(self.server.views.baseurl, text=SLICING_QUERYSET_PAGE_1.read_text())
loop = self.server.views.fields("id", "name")
list(loop)
history = m.request_history[0]

fields = history.qs.get("fields", [""])[0].split(",")

assert fields[0] == "_default_"
assert "id" in fields
assert "name" in fields

def test_queryset_field_all(self) -> None:
with requests_mock.mock() as m:
m.get(self.server.views.baseurl, text=SLICING_QUERYSET_PAGE_1.read_text())
loop = self.server.views.fields("id", "name", "_all_")
list(loop)
history = m.request_history[0]

fields = history.qs.get("fields", [""])[0]

assert fields == "_all_"
Loading