diff --git a/build.gradle.kts b/build.gradle.kts index a3ff210a85..d50d8a37fc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -78,6 +78,9 @@ allprojects { } } + tasks.findByName("nativeTest")?.run { + outputs.upToDateWhen { false } + } tasks.findByName("jvmTest")?.run { outputs.upToDateWhen { false } diff --git a/src/commonMain/kotlin/dev/evo/elasticmagic/Document.kt b/src/commonMain/kotlin/dev/evo/elasticmagic/Document.kt index 707cf24883..eb175275ec 100644 --- a/src/commonMain/kotlin/dev/evo/elasticmagic/Document.kt +++ b/src/commonMain/kotlin/dev/evo/elasticmagic/Document.kt @@ -126,11 +126,16 @@ class BoundJoinField( */ abstract class FieldSet : Named { private val fields: ArrayList = arrayListOf() - private val fieldsByName: HashMap = hashMapOf() + private val fieldsByName: HashMap = hashMapOf() internal fun addField(field: AnyField) { - fields.add(field) - fieldsByName[field.getFieldName()] = field + val existingFieldIx = fieldsByName[field.getFieldName()] + if (existingFieldIx != null) { + fields[existingFieldIx] = field + } else { + fieldsByName[field.getFieldName()] = fields.size + fields.add(field) + } } internal fun getAllFields(): List { @@ -138,7 +143,7 @@ abstract class FieldSet : Named { } internal fun getFieldByName(name: String): AnyField? { - return fieldsByName[name] + return fields[fieldsByName[name] ?: return null] } fun field(