Filter blank failedWhere Queries from mutator#1482
Filter blank failedWhere Queries from mutator#1482agusaldasoro wants to merge 8 commits intomasterfrom
Conversation
We were sending empty strings as a valid query
| val oldSqlActions = mutableListOf<EnvironmentAction>().plus(ind.seeInitializingActions()) | ||
|
|
||
| val failedWhereQueries = evaluatedIndividual.fitness.getViewOfAggregatedFailedWhereQueries() | ||
| .filter { it.isNotBlank() } |
There was a problem hiding this comment.
Hey! You are right, I moved the fix to that function
| .map { it.sqlCommand } | ||
| // JSQLParser >= 4.9 may produce empty-string SQL commands (it used to throw, now | ||
| // parses "" to null). Guard here at the source rather than at every call site. | ||
| .filter { it.isNotBlank() } |
There was a problem hiding this comment.
was this definition of aggregatedFailedWhereQueries correct? i mean, also the previous version. inside DatabaseExecution we keep track of all SQL commands done in a test. some have failedWhere, some do not. but here it seems like you mark everything under executionInfo as failedWhere, isn't it? this would work if and only if all queries had failedWhere, isn't it?
There was a problem hiding this comment.
just to be on safe side, can you add some tests to check this scenario?
There was a problem hiding this comment.
Shouldn't that be covered by line 169 .filter { it.failedWhere.isNotEmpty() }?
I added a test also to check both conditions failed where present and absent
There was a problem hiding this comment.
the class DatabaseExecution is old, where executionInfo was added later
/**
* When a test case is executed, and the SUT does access a SQL database,
* keep track of which SQL commands were executed.
*
* In particular, we keep track of which tables and columns were involved.
*
* For the Maps:
* key -> table name
* value -> column names, where "*" means all
*
*
* This class MUST be immutable
*/
class DatabaseExecution(
val queriedData: Map<TableId, Set<String>>,
val updatedData: Map<TableId, Set<String>>,
val insertedData: Map<TableId, Set<String>>,
val failedWhere: Map<TableId, Set<String>>,
val deletedData: List<TableId>,
val numberOfSqlCommands: Int,
val sqlParseFailureCount: Int,
val executionInfo: List<SqlExecutionInfo>
)
unless I m mistaken, executionInfo includes info for all SQL commands, even the ones that had no failed WHERE.

This pull request makes a focused improvement to the mutation logic for handling failed SQL WHERE queries in the
ApiWsStructureMutatorclass. The main change ensures that only non-blank failed WHERE queries are processed, which helps prevent unnecessary or invalid operations during mutation. We were sending empty strings as a valid query.ApiWsStructureMutator, the list of failed WHERE queries is now filtered to exclude blank entries before further processing. This helps avoid issues related to empty or invalid SQL queries during mutation.