Skip to content

[FIX] Use SQLAlchemy .is_(False) instead of Python identity check in test result filtering#1043

Merged
canihavesomecoffee merged 1 commit intoCCExtractor:masterfrom
Atul-Chahar:fix/sqlalchemy-identity-vs-equality
Mar 5, 2026
Merged

[FIX] Use SQLAlchemy .is_(False) instead of Python identity check in test result filtering#1043
canihavesomecoffee merged 1 commit intoCCExtractor:masterfrom
Atul-Chahar:fix/sqlalchemy-identity-vs-equality

Conversation

@Atul-Chahar
Copy link
Contributor

In raising this pull request, I confirm the following (please check boxes):

  • I have read and understood the contributors guide.
  • I have checked that another pull request for this purpose does not exist.
  • I have considered, and confirmed that this submission will be valuable to others.
  • I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
  • I give this submission freely, and claim no ownership to its content.

My familiarity with the project is as follows (check one):

  • I have never used the project.
  • I have used the project briefly.
  • I have used the project extensively, but have not contributed previously.
  • I am an active contributor to the project.

Summary

Fixes a silent SQLAlchemy filter bug in get_test_results() (mod_test/controllers.py:102).

The Bug

# Before — Python identity check (always False for a column attribute):
RegressionTestOutput.ignore is False

# After — SQLAlchemy column comparison:
RegressionTestOutput.ignore.is_(False)

RegressionTestOutput.ignore is a Column(Boolean()). Using Python's is False performs an identity check — "is this column attribute the exact same object as False?" — which is always False. This means the and_() filter always evaluates to filter(and_(..., False)), returning no results.

Impact

In the "no result files" branch of get_test_results() (line 98-109), when a regression test has non-ignored output files but the test produced no result files, the broken filter returns nothing. The len(outputs) > 0 check on line 105 is therefore never true, so the test entry is not flagged as an error — silently appearing as passing.

Changes

  • 1 line changed in mod_test/controllers.py:102
  • pycodestyle ✅ passes
  • Module import ✅ successful

Fixes #1042

@Atul-Chahar
Copy link
Contributor Author

Local Verification

$ ./venv/bin/pycodestyle mod_test/controllers.py --config=.pycodestylerc
(no output — all clean)

$ ./venv/bin/python -c "from mod_test.controllers import *; print('Import OK')"
Import OK

Note: Full test suite requires MySQL which I don't have locally — CI should cover this. The change is a single-line fix to a well-documented SQLAlchemy anti-pattern (is False vs .is_(False)), so the risk is minimal.

Replace 'RegressionTestOutput.ignore is False' with
'RegressionTestOutput.ignore.is_(False)' in get_test_results().

Python's 'is False' performs an identity check against the False
singleton, which always evaluates to False for a SQLAlchemy column
attribute. This caused the filter to silently return no results,
meaning tests with missing (non-ignored) output files were not
flagged as errors.

Fixes CCExtractor#1042
@canihavesomecoffee canihavesomecoffee force-pushed the fix/sqlalchemy-identity-vs-equality branch from 8248bcb to bbae567 Compare March 5, 2026 21:15
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 5, 2026

@canihavesomecoffee canihavesomecoffee merged commit 8ec24f2 into CCExtractor:master Mar 5, 2026
6 checks passed
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.

[BUG] SQLAlchemy identity comparison (is False) silently breaks test result filtering

2 participants