Skip to content

Fix: Resolve PG17 incompatibility for ENUMS in CASE statements #6099

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 3 commits into
base: master
Choose a base branch
from

Conversation

vcovo
Copy link

@vcovo vcovo commented May 27, 2025

Motivation

I have a postgresql 17.3 DB that I also wanted to use for the results of the trials ran through Optuna - potentially linking them with my own tables through a common id. Unfortunately this lead to an error: operator does not exist: trialvaluetype = character varying error when using PostgreSQL 17.3 as explained in #6096.

Description of the changes

This changes the SQLAlchemy case() structure in TrialModel.find_max/min_value_trial_id to directly compare the ENUM column with Python ENUM members, avoiding problematic VARCHAR casts on string literals.

@HideakiImamura
Copy link
Member

@c-bata @gen740 @sawa3030 Could you review this PR?

@gen740
Copy link
Member

gen740 commented May 30, 2025

@vcovo
Could you update .github/workflows/tests-storage.yml to include tests for PostgreSQL with psycopg3?
There are already existing tests for psycopg2, so I believe it should be straightforward to update by referring to those lines.

Copy link
Contributor

github-actions bot commented Jun 8, 2025

This pull request has not seen any recent activity.

@github-actions github-actions bot added the stale Exempt from stale bot labeling. label Jun 8, 2025
@github-actions github-actions bot removed the stale Exempt from stale bot labeling. label Jun 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants