jOOQ / jOOQ/jOOQ

Wrong import generated for Array[X] user type in ScalaGenerator

Open
#19,085 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C: Code Generation C: Integration: Scala E: All Editions P: Medium T: Defect
Dominant language
Java
Stars
6.8k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

I've just added an integration test like this:

<forcedType>
    <userType>Array[org.jooq.codegen.test.udtsforpostgresconverters.U2Wrapper]</userType>
    <converter>org.jooq.codegen.test.udtsforpostgresconverters.U2ArrayConverter</converter>
    <includeExpression>T1\.C2_ARRAY</includeExpression>
</forcedType>

This resulted in bad code being generated:

import Array

The workaround is:

<forcedType>
    <userType>scala.Array[org.jooq.codegen.test.udtsforpostgresconverters.U2Wrapper]</userType>
    <converter>org.jooq.codegen.test.udtsforpostgresconverters.U2ArrayConverter</converter>
    <includeExpression>T1\.C2_ARRAY</includeExpression>
</forcedType>

The types in the scala package probably shouldn't be imported. Or rather, the specific improvement is to not import unqualified types from forcedType configurations.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the ScalaGenerator code involved in imports and the integration test described in the issue. Reproduce the generated Scala code using the forcedType configuration with Array[org.jooq.codegen.test.udtsforpostgresconverters.U2Wrapper], then verify that unqualified forcedType types and types from the scala package are not emitted as imports.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, scala
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.