Skip to content

Restrict BOOL columns to boolean values - #1841

Merged
arcuri82 merged 2 commits into
masterfrom
fix/smtlib-bool-domain
Oct 7, 2026
Merged

arcuri82 merged 2 commits into
masterfrom
fix/smtlib-bool-domain

Conversation

@agusaldasoro

@agusaldasoro agusaldasoro commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

A boolean column is encoded as an SMT String, and SmtLibGenerator.appendBooleanConstraints restricts it to "true" or "false". That restriction was only applied when the declared type was exactly BOOLEAN. TYPE_MAP also accepts BOOL, which is how PostgreSQL reports a boolean column, and SMTLibZ3DbConstraintSolver already treats it as boolean when rebuilding genes (BOOLEAN_SPELLINGS).

A bool column therefore had no domain, and Z3 could give it any string. For WHERE active <> false, Z3 picks "". toBoolean("") reads that back as false, so the generated row violates the very query it was generated for.

Fix

  • SmtLibGenerator.BOOLEAN_TYPES (BOOLEAN, BOOL) is the single set of boolean spellings.
  • appendBooleanConstraints uses it, so a bool column gets the same domain as a BOOLEAN one.
  • SMTLibZ3DbConstraintSolver.BOOLEAN_SPELLINGS now refers to the same set instead of repeating it, so the domain constraint and the gene reconstruction cannot drift apart again.

Tests

New BooleanColumnSolvingTest.boolSpellingIsRestrictedToBooleanValues, end to end against Z3. It uses the same H2 table with the column type set to "bool" and solves WHERE active <> false and WHERE active <> true. On master, the first case fails with expected: <true> but was: <false>. The second one only passes on master because "" happens to read back as false.

All tests under org.evomaster.core.database.sql.solver pass.

  The "true"/"false" domain was only asserted for columns declared
  BOOLEAN, although TYPE_MAP and gene reconstruction also accept BOOL
  (PostgreSQL's spelling). A bool column could take any string, so
  WHERE active <> false yielded "", read back as false. Both now use a
  single set of boolean spellings.
@agusaldasoro agusaldasoro changed the title Restrict BOOL columns to boolean values Restrict BOOL columns to boolean values Oct 7, 2026
@agusaldasoro
agusaldasoro marked this pull request as ready for review October 7, 2026 12:51
@agusaldasoro
agusaldasoro requested a review from jgaleotti October 7, 2026 12:51
@jgaleotti
jgaleotti requested a review from arcuri82 October 7, 2026 13:40
@arcuri82
arcuri82 merged commit 8d126ed into master Oct 7, 2026
33 checks passed
@arcuri82
arcuri82 deleted the fix/smtlib-bool-domain branch October 7, 2026 19:23
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.

3 participants