andrewoma/kwery

`Table#allColumns` doesn't return a valid collection unless one of the other `*Columns` or `type` properties are accessed

Closed this issue · 0 comments

    @Test
    fun `test allColumns returns a valid collection`() {
        val usersTable = UsersTable()
        assert(usersTable.allColumns.isNotEmpty())
    }

    private data class User(val id: String, val name: String, val age: Int)
    private class UsersTable : Table<User, UUID>("users") {
        val id by col(User::id, id = true)
        val userName by col(User::name)
        val age by col(User::age)

        override fun create(value: Value<User>): User {
            return User(value of id, value of userName, value of age)
        }

        override fun idColumns(id: UUID): Set<Pair<Column<User, *>, *>> {
            return setOf(this.id to id)
        }
    }