Skip to content

Invalid handling of object Arrays in querydsl-kotlin-codegen #1789

Description

@NersesAM

Describe the bug
there is a bug in querydsl-kotlin-codegen when using object arrays, such as String[]

To Reproduce
here is a test case to reproduce for EntitySerializerTest

    @Test
    fun object_array() {
        val type = SimpleType(TypeCategory.ENTITY, "Entity", "", "Entity", false, false)
        val entityType = EntityType(type)
        entityType.addProperty(Property(entityType, "tags", ClassType(TypeCategory.ARRAY, Array<String>::class.java)))
        typeMappings.register(entityType, queryTypeFactory.create(entityType))
        serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, JavaWriter(writer))
        Assertions.assertTrue(writer.toString().contains("val tags: ArrayPath<Array<String>, String>"))
        Assertions.assertTrue(writer.toString().contains("createArray(\"tags\", Array<String>::class.java)"))
        assertCompiles("QEntity", writer.toString())
    }

this generates a kotlin class with public val tags: ArrayPath<String[], String> = createArray("tags", String[]::class.java) which is invalid and fails to compile.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions