Hi all, does anyone have any ideas on what may be ...
# exposed
s
Hi all, does anyone have any ideas on what may be causing this BatchDataInconsintentException in my ktor backend (using exposed): https://stackoverflow.com/questions/78815853/batchdatainconsistentexception-in-exposed-despite-providing-all-non-auto-generat
c
Hi @Stelios Papamichail Has this been resolved on your end? Any minimally reproducible sample (with the missing entities and reference relations for example) would be helpful to properly debug this (with or without Ktor), but let's see what we can do in the meantime. Have you been able to validate in some way that the values for the columns mentioned in the exception are actually being provided to the new entity instance? For example, you could try hooking into
new()
to confirm before the entity gets flushed and the attempt is made to prepare the batch insert statement:
Copy code
class PhdInstitutionEntity(id: EntityID<Int>) : IntEntity(id) {
    companion object : IntEntityClass<PhdInstitutionEntity>(PhdInstitutionsTable) {
        override fun new(init: PhdInstitutionEntity.() -> Unit): PhdInstitutionEntity {
            val newInstitution = super.new(init)
            newInstitution.writeValues.forEach { (column, value) ->
                println("Received $value for column ${column.name}")
            }
            return newInstitution
        }
    }
    // ... entity fields
}
If all columns from
PhdInstitutionsTable
are accounted for in the new entity's
writeValues
and this exception is still thrown, please consider sharing a sample project on YouTrack so we can look further into our internal statement validation. Please also share any other relevant details, like the Exposed version and database being used.