0

我在我的 Web 应用程序中使用 Kotlin Exposed for ORM。我有一个实体用户,它是在数据库中创建的

线程“main” org.postgresql.util.PSQLException 中的异常:错误:列 users.emailSituation 不存在 提示:也许您的意思是引用列“users.emailsituation”。职位:59

我的数据库是postgresql

用户实体:

object Users : IntIdTable() {
    val name = text("name").index()
    val family = text("family").index()
    val email = text("email").index()
    val emailSituation = bool("emailSituation")
    val mobile = long("mobile").index()
}

class User(id: EntityID<Int>) : IntEntity(id) {
    companion object : IntEntityClass<User>(Users)

    var name by Users.name
    var family by Users.family
    var email by Users.email
    var emailSituation by Users.emailSituation
    var mobile by Users.mobile
}

找到一个值:

transaction {
        logger.addLogger(StdOutSqlLogger)
 println("User: ${User.find { Users.mobile eq 87654 }.joinToString {it.name}}")
    }

我该如何解决?

4

1 回答 1

1

The error seems to indicate that it is trying to query for a column called emailSituation, but only emailsitutation is available. This might have to do with how the query is ultimately being constructed by your library. Postgres will generally accept anything and lowercase it for column names unless you quote it (which is probably out of your control). To get around this, try lowercasing the name of the column you map to:

Change:

val emailSituation = bool("emailSituation")

To:

val emailSituation = bool("emailsituation")
                                ^
                                +-- That's the difference
于 2018-05-12T13:05:03.747 回答