sqlalchemy icon indicating copy to clipboard operation
sqlalchemy copied to clipboard

Move Operator.is_ and Operator.is_not to OperatorClass.BASE

Open CaselIT opened this issue 1 month ago • 10 comments

Operator.is_ and Operator.is_not seem to be part of OperatorClass.COMPARISON. which is not part of HSTORE because you can't say hstore_col > value.

I think it's by definition that no datatype in SQL can't be in a NULL column, so this suggests that Operator.is_ and Operator.is_not should be part of OperatorClass.BASE and not OperatorClass.COMPARISON.

so a bigger-scoped change. (it's all just "do we warn or not" in the end though, it shouldn't cause a problem)

Originally posted by @zzzeek in https://github.com/sqlalchemy/sqlalchemy/discussions/13712#discussioncomment-19123424

CaselIT avatar Oct 26 '26 13:10 CaselIT

sort of a regression too right

zzzeek avatar Oct 26 '26 14:10 zzzeek

Yeah probably, but I think it's mainly in exotic types that's include comparison as op class. Most types should not be impacted

CaselIT avatar Oct 26 '26 14:10 CaselIT

Would you accept an AI-assisted patch moving is_ and is_not to OperatorClass.BASE? It includes regression tests for HSTORE and a BASE-only type: four cases fail before the fix and pass afterward, while unsupported ordering still warns.

If that scope is suitable, could you add the “open for pull requests” label?

OllieinCanada avatar Oct 26 '26 16:10 OllieinCanada

I think it's best of it's done internally @OllieinCanada, thanks

CaselIT avatar Oct 26 '26 16:10 CaselIT

@CaselIT Thanks for clarifying; I'll leave #13719 to the team. Are there other SQLAlchemy tasks where you'd welcome outside help, particularly regression tests, bug reproduction, or maintenance work? I use AI assistance and would follow the project's contribution requirements. I'd appreciate a pointer to something useful to the team.

OllieinCanada avatar Oct 26 '26 18:10 OllieinCanada

@zzzeek I think some bigger changes are needed:

  • is_distinct_from/is_not_distinct_from are likely also base.
  • we may want to split eq/ne/in_ etc from the other comparison ones. For example HSOTRE supports = and in but not <

Maybe a new EQUALITY class?

CaselIT avatar Oct 26 '26 21:10 CaselIT

Federico Caselli has proposed a fix for this issue in the main branch:

don't treat is_ / is_not as COMPARISON operators https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/7128

sqla-tester avatar Oct 26 '26 21:10 sqla-tester

sure if it doesnt look awful

zzzeek avatar Oct 26 '26 21:10 zzzeek

Hey, just updated to 2.1.7, can confirm my original issue is fixed, thanks!

But I now hit the same issue with is_distinct_from/is_not_distinct_from, as you suspected @CaselIT. (nothing blocking, I'll just ignore the warning for now!)

[edit] also have issues with some == usages, which are valid operations for HSTORE: would they be included in the EQUALITY class you mentioned?

loic-simon avatar Nov 03 '26 22:11 loic-simon

I've tried to improve things a bit here https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/7175

CaselIT avatar Nov 07 '26 16:11 CaselIT