babyfish-ct / jimmer

A revolutionary ORM framework for both java and kotlin.
Apache License 2.0
876 stars 88 forks source link

'AssertionError: Internal bug: Join property has not storage' when query with ManyToManyView #776

Closed ForteScarlet closed 1 week ago

ForteScarlet commented 1 week ago

Hi. When I try to use a deep level ManyToManyView condition in the query, I get an error: AssertionError: Internal bug: Join property has not storage.

The test

    @Test
    @Transactional
    fun queryTest() {
        // Will be crashed.
        val err = assertFails {
            sql.createQuery(SystemPermission::class) {
                where(table.roles { accounts { id eq 1 } })
                select(table)
            }.execute()
        }

        assertIs<AssertionError>(err)
        assertEquals("Internal bug: Join property has not storage", err.message)

        // Will work fine.
        val permissions = sql.createQuery(SystemPermission::class) {
            where(table.roleMappings { role.accountMappings { account.id eq 1 } })
            select(table)
        }.execute()

        assertEquals(8, permissions.size)

        // Throw the error here.
        throw err
    }

The entities

Here is a small reproduction package with information on entities and SQL.

Bonus information: the above logic does not crash if ManyToMany is used directly.

babyfish-ct commented 1 week ago

Try 0.9.15