Repository navigation
Generate valid UUID, JSON and JSONB values - #1849
Merged
Merged
Conversation
UUID and JSONB columns are unconstrained SMT strings, so unless the query pinned the value Z3 picked one such as "", and the database rejected the INSERT of the whole row. A value that is not a valid UUID or JSON document is now mapped deterministically to one, which keeps the equalities imposed by keys and foreign keys.
agusaldasoro
added this pull request to stack #1848
October 7, 2026 13:02
agusaldasoro
removed this pull request from stack #1848
October 7, 2026 13:04
agusaldasoro
changed the base branch from
fix/smtlib-date-string-literals
to
master
October 7, 2026 13:04
agusaldasoro
marked this pull request as ready for review
October 8, 2026 17:34
jgaleotti
approved these changes
Oct 8, 2026
arcuri82
approved these changes
Oct 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
UUIDandJSONBcolumns are encoded as SMTStrings, with nothing constraining their form. Unless the query pins the value, Z3 assigns something like""or"!0!", and the INSERT of the whole row is rejected (H2:Data conversion error converting "''" (EV: "U" UUID)).UUIDcolumn therefore got its rows inserted only for queries that compare that column with a literal.UUIDcolumns failed on both rows.The failure is silent, because
SqlScriptRunner.execInsertlogs a failed insertion and carries on.JSON, the type of MySQL, H2 2.x and PostgreSQL's non-binary variant, was not inTYPE_MAPat all. Every table of the schema is declared for every query, so a singleJSONcolumn made generation fail for all queries of the schema.Fix
SMTLibZ3DbConstraintSolver.validTextValueturns the value Z3 assigned into one the database accepts, when building theStringGene:UUID: a value that is not a UUID becomesUUID.nameUUIDFromBytes(value).JSONandJSONB: a value that is not a JSON document becomes that value as a JSON string (""→"\"\""). Validity is checked with Jackson, rejecting trailing tokens and blank input.The mapping is deterministic: equal strings give equal values and different strings give different ones. The equalities and distinctions the formula imposes (foreign keys, unique and primary keys) therefore still hold after the mapping.
Constraining the form inside the formula, with
str.in_reand a UUID pattern, would also work. It brings in Z3's regular-expression theory, though, which makes solving noticeably more expensive, so post-processing was preferred.UUID_TYPE,JSON_TYPEandJSONB_TYPEare now constants inSmtLibGenerator, used byTYPE_MAP, which now mapsJSONlikeJSONB.Tests
New
UuidJsonColumnSolvingTest, end to end against Z3 and H2:UUIDfree: the row is inserted and returned;UUIDto a literal: the literal is kept;UUIDforeign key: both rows are inserted, and the reference holds;JSONcolumn: the row is inserted and returned;JSONBcolumn (an H2varcharreported asjsonb): the generated value is a JSON document.On
masterevery case fails, because theJSONcolumn breaks generation for the whole schema. Without that column, all but the pinned-literal case fail, e.g.expected: <[true, true]> but was: <[false, false]>for the foreign key.All tests under
org.evomaster.core.database.sql.solverpass.