Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

interface 注解遇到 operator 关键字生成错误 #18

Open
onXoot opened this issue Sep 21, 2022 · 1 comment
Open

interface 注解遇到 operator 关键字生成错误 #18

onXoot opened this issue Sep 21, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@onXoot
Copy link

onXoot commented Sep 21, 2022

ktorm-ksp version: 1.0.0-RC3
ktorm version: 3.5.0

code

@org.ktorm.ksp.api.Table("test")
interface TestOperator: org.ktorm.entity.Entity<TestOperator> {
    @org.ktorm.ksp.api.PrimaryKey
    var id: Long
    var operator: String
}

自动生成的代码

@Suppress("FunctionName")
public fun TestOperator(id: Long? = undefined(), operator_: String = undefined()): TestOperator {
    val entity = Entity.create<TestOperator>()
    if (id !== undefined<Long?>()) {
        entity.id = id ?: error("`entity` should not be null.")
    }
    if (operator !== undefined<String>()) {
        entity.operator = operator
    }
    return entity
}

public fun TestOperator.copy(id: Long? = undefined(), operator_: String = undefined()):
        TestOperator {
    val entity = this.copy()
    if (id !== undefined<Long?>()) {
        entity.id = id ?: error("`entity` should not be null.")
    }
    if (operator !== undefined<String>()) {
        entity.operator = operator
    }
    return entity
}

operator 在参数上自动加了个下划线,但是下面使用的时候没加 导致编译失败

使用实体类形式可以编译成功

@vincentlauvlwj vincentlauvlwj added the bug Something isn't working label Sep 21, 2022
@vincentlauvlwj
Copy link
Member

好的,谢谢

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

No branches or pull requests

2 participants