Skip to content

Commit 24d9663

Browse files
authored
Merge pull request #1456 from WebFuzzing/fix/solver-test-sql
Fix test
2 parents 0ab5b55 + e64a7db commit 24d9663

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

core-tests/e2e-tests/spring/spring-rest-h2-z3solver/src/test/java/org/evomaster/e2etests/spring/h2/z3solver/Z3SolverEMTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import org.evomaster.core.problem.rest.data.RestIndividual;
66
import org.evomaster.core.search.Solution;
77
import org.junit.jupiter.api.BeforeAll;
8-
import org.junit.jupiter.api.Disabled;
98
import org.junit.jupiter.api.Test;
109

1110
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -18,7 +17,6 @@ public static void initClass() throws Exception {
1817
SpringTestBase.initClass(new Z3SolverController());
1918
}
2019

21-
@Disabled("FIXME new invariants fail here... need to update solver code to handle them")
2220
@Test
2321
public void testRunEM() throws Throwable {
2422

core/src/main/kotlin/org/evomaster/core/solver/SMTLibZ3DbConstraintSolver.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,13 @@ class SMTLibZ3DbConstraintSolver() : DbConstraintSolver {
139139
// Find table from schema and create SQL actions
140140
val table = findTableByName(schemaDto, tableName)
141141

142+
/*
143+
* The invariant requires that action.insertionId == primaryKey.uniqueId (and same for FK).
144+
* So we must use the same id for the action and all its PK/FK genes.
145+
*/
146+
val actionId = idCounter
147+
idCounter++
148+
142149
// Create the list of genes with the values
143150
val genes = mutableListOf<Gene>()
144151
for (columnName in columns.fields) {
@@ -164,15 +171,13 @@ class SMTLibZ3DbConstraintSolver() : DbConstraintSolver {
164171
}
165172
val currentColumn = table.columns.firstOrNull(){ it.name.equals(columnName, ignoreCase = true) }
166173
if (currentColumn != null && currentColumn.primaryKey) {
167-
gene = SqlPrimaryKeyGene(columnName, table.id, gene, idCounter)
168-
idCounter++
174+
gene = SqlPrimaryKeyGene(columnName, table.id, gene, actionId)
169175
}
170176
gene.markAllAsInitialized()
171177
genes.add(gene)
172178
}
173179

174-
val sqlAction = SqlAction(table, table.columns, idCounter, genes.toList())
175-
idCounter++
180+
val sqlAction = SqlAction(table, table.columns, actionId, genes.toList())
176181
actions.add(sqlAction)
177182
}
178183

0 commit comments

Comments
 (0)