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

Feat: Updates colspec to account for sqlalchemy Enum #1111

Merged
merged 2 commits into from
Aug 14, 2024
Merged

Conversation

chalmerlowe
Copy link
Collaborator

@chalmerlowe chalmerlowe commented Aug 14, 2024

Flakybot was flagging a number of tests that failed when handling sqlalchemy Enums. In consultation with members of the sqlalchemy team, it was suggested to follow an approach similar to the one used by sqlite: To modify the colspec.

The backstory is this:
We made a class (BQString) that inherits from sqlalchemy's String.
BQString has one function (and only one).
It will process string literals to replace single percents with double percents.

def process_string_literal(value):
    return repr(value.replace("%", "%%"))


class BQString(String):
    def literal_processor(self, dialect):
        return process_string_literal

Where the issue comes into play is this:

The problem is that Enum is a subclass of String, so if you are defining a new dialect specific class of String, you would need to accommodate for Enum as well. The simplest way assuming you don't need BQString's logic for Enum is to map Enum to itself, which would bypass the BQString type for Enum.

Fixes #1102 🦕
Fixes #1103 🦕
Fixes #1104 🦕
Fixes #1105 🦕
Fixes #1106 🦕
Fixes #1107 🦕
Fixes #1108 🦕

@product-auto-label product-auto-label bot added the size: xs Pull request size is extra small. label Aug 14, 2024
Copy link

conventional-commit-lint-gcf bot commented Aug 14, 2024

🤖 I detect that the PR title and the commit message differ and there's only one commit. To use the PR title for the commit history, you can use Github's automerge feature with squashing, or use automerge label. Good luck human!

-- conventional-commit-lint bot
https://conventionalcommits.org/

@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/python-bigquery-sqlalchemy API. label Aug 14, 2024
@chalmerlowe chalmerlowe added the owlbot:run Add this label to trigger the Owlbot post processor. label Aug 14, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Aug 14, 2024
@chalmerlowe chalmerlowe marked this pull request as ready for review August 14, 2024 14:05
@chalmerlowe chalmerlowe requested review from a team as code owners August 14, 2024 14:05
@chalmerlowe chalmerlowe requested a review from tswast August 14, 2024 14:05
@chalmerlowe chalmerlowe added the owlbot:run Add this label to trigger the Owlbot post processor. label Aug 14, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Aug 14, 2024
@chalmerlowe chalmerlowe requested a review from suzmue August 14, 2024 16:51
@tswast tswast merged commit b54bdde into main Aug 14, 2024
17 checks passed
@tswast tswast deleted the flaky-bot-enum-II branch August 14, 2024 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment