Skip to content

fix: keep _default_ when fields() is chained on a QuerySet - #1927

Open
ranjithguggilla wants to merge 1 commit into
tableau:developmentfrom
ranjithguggilla:fix/queryset-fields-default-token
Open

ranjithguggilla wants to merge 1 commit into
tableau:developmentfrom
ranjithguggilla:fix/queryset-fields-default-token

Conversation

@ranjithguggilla

Copy link
Copy Markdown

Motivation

QuerySet.fields() is documented to request _default_ plus the fields the caller names. It built that token with set(("_default_")). Those parentheses do not make a tuple, so the value is the set of characters in the string.

Calling fields() on the endpoint is fine. QuerysetEndpoint.fields() already uses set(("_default_",)). The broken call is the one that follows filter(), order_by(), paginate() or all(), because those return a QuerySet and the next .fields() is QuerySet.fields().

server.views.filter(name="Sales").fields("id", "name")
# sent     fields=_,a,d,e,f,id,l,name,t,u
# should   fields=_default_,id,name

I found this while reading query.py. There is no issue for it. Closed #1620 is a separate report: the server wants _default_ first, and this client already sorts the field list.

Behavior change

A chained .fields(...) now sends _default_ together with the named fields, the same as calling .fields(...) on the endpoint.

CHANGELOG.md only points at the Releases page, so there is no Unreleased section to update.

Test plan

  • test_queryset_chained_fields checks the set stored on the request options after filter(...).fields(...).
  • test_queryset_chained_fields_query_string checks the fields query parameter after order_by(...).fields(...).
  • Both fail on the old line and pass with this change.
  • pytest test on Python 3.13: 1051 passed, 1 skipped. The same counts were recorded on Python 3.10 and 3.14. black --check --line-length 120 and the CI mypy command are clean.
  • I have no Tableau Server, so I have not checked how the server responds to the old character list.

QuerySet.fields() built the default token with set(("_default_")), which
is a set of the string's characters. A call such as
server.views.filter(name="x").fields("id") sent
fields=_,a,d,e,f,id,l,t,u instead of fields=_default_,id.

QuerysetEndpoint.fields() already used a one-element tuple, so only the
chained form was affected.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Field parameter is order specific

1 participant