https://kotlinlang.org logo
#exposed
Title
# exposed
e

Emil Kantis

05/02/2021, 5:33 PM
I'm getting some odd error regarding with DAOs when writing tests
<http://dao.Companies.org|dao.Companies.org>_id is not in record set
. All tables are created in the same transaction as the test then everything is rolled back. I've tried using both H2 and SQLite, getting same error with both.. Not sure where to start looking. Most search hits seems to be related to renaming the id column, but this is a FK to another entity
m

Marcus Ilgner

05/02/2021, 6:20 PM
That message sounds like the column isn't being selected from the database or an invalid value being assigned to the column. Do you have a link to or a snippet of the test code? Are you using select or slice to adjust the columns?
e

Emil Kantis

05/02/2021, 8:10 PM
There's no slicing or stuff like that. In fact, the entity/table mentioned is not even involved in the query triggering the exception.. But I guess that's due to a flush happening as a result of the query taking place? I have an entity called
Organisation
with a 1-* relationship with
OrganisationFeature
that I'm querying as such:
Copy code
fun isEnabled(organisation: Organisation) =
        organisation.features.any { it.feature == this }
The above call triggers the exception mentioning
Company
which is only involved at the call site, like this:
Copy code
when (TEAM_LEAD_AS_PROJECT_MANAGER.isEnabled(project.company.organisation)) {
            true -> activeManagers(project)
            false -> emptyList()
        }
Found the issue..
Copy code
class OrganisationFeature(id: EntityID<Int>) : IntEntity(id) {
    companion object : IntEntityClass<OrganisationFeature>(OrganisationFeatures)

    var organisation by Organisation referencedOn Companies.organisationId
    var feature by OrganisationFeatures.feature
}
👍 1
11 Views