Skip to content
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

Encode roles as in JDBC driver #311

Merged
merged 1 commit into from
Jan 5, 2023

Conversation

mdesmet
Copy link
Contributor

@mdesmet mdesmet commented Jan 5, 2023

Description

In the jdbc driver custom roles are enclosed in ROLE{rolename} automatically. This was not yet implemented in the Trino python client, causing confusion.

This PR adds this enclosing automatically, while checking if the enclosing is not already provided to ensure backwards compatiblity.

Non-technical explanation

Release notes

( ) This is not user-visible or docs only and no release notes are required.
( ) Release notes are required, please propose a release note for me.
( ) Release notes are required, with the following suggested text:

* Enclose custom roles passed in Connection into Trino protocol specific formatting (ROLE{rolename})

@cla-bot cla-bot bot added the cla-signed label Jan 5, 2023
Copy link
Member

@hovaesco hovaesco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for doing this, maybe we should also have an example with an old approach in README?

@mdesmet mdesmet force-pushed the feat/enhance-roles-parameter branch from 3d36ad1 to 2dc08c6 Compare January 5, 2023 10:21
@mdesmet mdesmet requested a review from hashhar January 5, 2023 10:40
@mdesmet
Copy link
Contributor Author

mdesmet commented Jan 5, 2023

Thank you for doing this, maybe we should also have an example with an old approach in README?

Well, the old approach is not anymore relevant after this PR. Our docs were already compliant, see https://github.com/trinodb/trino-python-client/blob/master/README.md#roles

@mdesmet mdesmet self-assigned this Jan 5, 2023
@hashhar hashhar merged commit 62ffa49 into trinodb:master Jan 5, 2023
@hashhar hashhar mentioned this pull request Jan 6, 2023
def _format_roles(self, roles):
formatted_roles = {}
for catalog, role in roles.items():
if role in ("NONE", "ALL") or ROLE_PATTERN.match(role) is not None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If role matches the ROLE_PATTERN can we use warnings.warn to tell user to fix it instead of silently accepting it?

Long term supporting both syntaxes may not actually solve the confusion.

@mdesmet Can you do this as a follow-up PR?

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

Successfully merging this pull request may close these issues.

3 participants