Skip to content

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

Description

@NersesAM

Important Notice

  • I am willing to put in the work and submit a PR to resolve this issue.

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions