Skip to content

Preserve Chemical Comparison Semantics - #36

Merged
asiomchen merged 8 commits into
mainfrom
toolkits-compare
May 24, 2026
Merged

asiomchen merged 8 commits into
mainfrom
toolkits-compare

Conversation

@asiomchen

Copy link
Copy Markdown
Owner

Summary

This PR fixes comparator behavior for Bingo and RDKit SQLAlchemy columns so Python operators preserve expected chemical semantics without breaking SQL NULL handling or SQLAlchemy internals.

Key Changes

  • Bingo != on molecule and reaction columns now delegates literal values to chemical negative exact matching via .not_equals(...).
  • Bingo == with a column RHS now preserves chemical exact matching instead of falling back to raw SQL equality.
  • Bingo == None and != None preserve SQLAlchemy NULL behavior as IS NULL and IS NOT NULL.
  • RDKit == None for molecule and reaction columns now preserves SQLAlchemy IS NULL behavior.
  • Bingo exact-search expressions now remain bool-compatible for SQLAlchemy identity checks, preserving index/list membership behavior.

Why This Matters

Raw SQL string equality is not chemically equivalent for molecules represented in different notations, such as CCO and OCC. Bingo column-to-column equality must therefore compile to Bingo exact search:

structure @ CAST((query_structure, '') AS bingo.exact)

At the same time, common NULL filters must remain standard SQL:

structure IS NULL
structure IS NOT NULL

@codecov

codecov Bot commented May 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 74.78992% with 30 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.92%. Comparing base (57eb0ed) to head (cd06bb6).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/molalchemy/rdkit/proxy.py 68.18% 14 Missing ⚠️
src/molalchemy/bingo/comparators.py 71.42% 4 Missing and 4 partials ⚠️
src/molalchemy/rdkit/comparators.py 62.50% 3 Missing and 3 partials ⚠️
src/molalchemy/bingo/proxy.py 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #36      +/-   ##
==========================================
- Coverage   82.27%   81.92%   -0.35%     
==========================================
  Files          24       25       +1     
  Lines        1709     1826     +117     
  Branches       41       62      +21     
==========================================
+ Hits         1406     1496      +90     
- Misses        294      315      +21     
- Partials        9       15       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@asiomchen
asiomchen merged commit 134616e into main May 24, 2026
15 of 17 checks passed
@asiomchen
asiomchen deleted the toolkits-compare branch May 24, 2026 19:24
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.

1 participant