Skip to content

[BUG] - JsonConverter + .dto 的 flat 函数 出现生成解析错误 #937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
TrueNine opened this issue Feb 21, 2025 · 6 comments
Closed
Labels
bug Something isn't working

Comments

@TrueNine
Copy link

Jimmer Version

0.9.57

JDK Version

23 + kotlin 2.1.20-RC

Database

PostgreSQL

OS

Windows

Expected behavior

当 使用 flat 函数对 spec 对象进行平展时,如果携带有 @JsonConverter 则只会使用 当前 EntityProps.FIELD.unwrap().getConverter,而不是 flat 对象的 converter

Actual behavior

假定两个实体 A B ,A 包含 B 字段,为 A 建立 dto 文件且新建 spec ASpec。

specification ASpec {
    flat(b) {
        bJsonConverterField
    }
}

如果此时进行 编译(特指 ksp),则会生成如下 _convert

public fun _convertDisCertCode(`value`: String?): String? {
        if (value === null) {
            return null
        }
        return AProps.B_JSON_CONVERTER_FIELD.unwrap().getConverter<String?, String>().input(value)
    }

Description

如上所述,此错误会造成编译错误

Reproduction steps

按照如上描述,嵌套建立即可

Generated SQL

No response

Relation Model

b { bJsonField: String? }
a { b }

Screenshots

Image

Logs

e: file:///C:/project/tnmaster-server/build/generated/ksp/main/kotlin/com/tnmaster/dto/jimmer/userinfo/UserInfoAdminSpec.kt:122:30 Unresolved reference 'CERT_CODE'.

@TrueNine TrueNine added the bug Something isn't working label Feb 21, 2025
@TrueNine
Copy link
Author

TrueNine commented Feb 21, 2025

目前较为尴尬的解决方式是:在 spec 内建立临时变量且去除 flat,后续查询时进行再次赋值,这能达到效果,但较为繁琐。

@babyfish-ct
Copy link
Owner

无法重现

@TrueNine
Copy link
Author

先不关闭,我稍后再去测试下,并给出完整复现用例

@TrueNine
Copy link
Author

我建立了一个仓库,用来复现此问题,这目前在我的机器上仍然无法进行编译

Image

仓库地址 jimmer-playground
clone 地址 jimmer-playground

@TrueNine
Copy link
Author

无法重现

我建立了一个仓库,用来复现此问题,这目前在我的机器上仍然无法进行编译

Image

仓库地址 jimmer-playground clone 地址 jimmer-playground

babyfish-ct added a commit that referenced this issue Feb 24, 2025
@babyfish-ct
Copy link
Owner

Try 0.9.60

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants