-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
base: master
Are you sure you want to change the base?
Conversation
@vcovo |
This pull request has not seen any recent activity. |
@gen740 in case it was missed I added the requested tests. Let me know if anything is still missing for this to be merged. |
( | ||
TrialValueModel.value_type == TrialValueModel.TrialValueType.INF_NEG, | ||
-1, | ||
), | ||
( | ||
TrialValueModel.value_type == TrialValueModel.TrialValueType.FINITE, | ||
0, | ||
), | ||
( | ||
TrialValueModel.value_type == TrialValueModel.TrialValueType.INF_POS, | ||
1, | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[question] I didn't tested yet, but based on the error message, can we simply write these lines like this?
( | |
TrialValueModel.value_type == TrialValueModel.TrialValueType.INF_NEG, | |
-1, | |
), | |
( | |
TrialValueModel.value_type == TrialValueModel.TrialValueType.FINITE, | |
0, | |
), | |
( | |
TrialValueModel.value_type == TrialValueModel.TrialValueType.INF_POS, | |
1, | |
), | |
{"INF_NEG": -1, "FINITE": 0, "INF_POS": 1}, | |
value=TrialValueModel.value_type.value, |
Let me change the reviewer since I'll be on leave until the week after next. @y0z Could you review this PR? |
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.