Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ class RestSecurityBuilder {

// Create a copy of the individual
val copy = target.copy() as RestIndividual
val actionCopy = copy.seeMainExecutableActions().last() as RestCallAction
val actionCopy = copy.seeMainExecutableActions().last()

val genes = GeneUtils.getAllStringFields(actionCopy.parameters)
.filter { it.staticCheckIfImpactPhenotype() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,6 @@ class SqlForeignKeyGene(
throw IllegalArgumentException("Invalid delta: $delta")
}
uniqueId += delta
if(isBound()){
val ind = getRoot() as EnterpriseIndividual
val action = ind.seeSqlDbActions().find{it.insertionId == uniqueIdOfPrimaryKey}
?: throw IllegalStateException("FK in $uniqueId is bound to PK $uniqueIdOfPrimaryKey," +
" but there is no action found for it")
if(!action.representExistingData) {
// as the ids of existing data is never modified, we shall not change the links to them
uniqueIdOfPrimaryKey += delta
}
}
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.evomaster.core.search.gene.sql

import org.evomaster.core.output.OutputFormat
import org.evomaster.core.problem.enterprise.EnterpriseIndividual
import org.evomaster.core.search.gene.root.CompositeGene
import org.evomaster.core.search.gene.Gene
import org.evomaster.core.search.impact.impactinfocollection.sql.SqlPrimaryKeyGeneImpact
Expand Down Expand Up @@ -50,6 +51,16 @@ class SqlPrimaryKeyGene(name: String,
if(delta <= 0){
throw IllegalArgumentException("Invalid delta: $delta")
}

//update all FKs pointing to this one
val ind = getRoot() as EnterpriseIndividual
ind.seeSqlDbActions()
.flatMap { it.seeAllGenes() }
.filterIsInstance<SqlForeignKeyGene>()
.filter{it.isBound() && it.uniqueIdOfPrimaryKey == uniqueId}
.forEach { it.uniqueIdOfPrimaryKey += delta }
// as the ids of existing data is never modified, we shall not change the links to them

uniqueId += delta
}

Expand Down
3 changes: 2 additions & 1 deletion core/src/main/kotlin/org/evomaster/core/sql/SqlAction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ class SqlAction(
if(delta <= 0){
throw IllegalArgumentException("Invalid delta: $delta")
}
insertionId += delta

seeAllGenes().forEach { g ->
if(g is SqlPrimaryKeyGene) {
Expand All @@ -100,6 +99,8 @@ class SqlAction(
g.shiftIdBy(delta)
}
}

insertionId += delta
}


Expand Down