当前位置: 首页 > 知识库问答 >
问题:

如何在kotlin暴露中选择别名列

乜嘉悦
2023-03-14

如何选择“按别名列分组”?我正在使用kotlin暴露。

fun getSubscribeInfoByRoleName(roleName: String): List<SubscribeInfo> {
        return SchemaSubscribersTable.join(SchemaVersionScheduleTable, JoinType.INNER, null, null) {
            SchemaSubscribersTable.schemaName eq SchemaVersionScheduleTable.schemaName }
                .slice(SchemaSubscribersTable.roleName, SchemaSubscribersTable.schemaName, SchemaVersionScheduleTable.version.max().alias("currentVersion"))
                .select { SchemaSubscribersTable.roleName.eq(roleName) and SchemaVersionScheduleTable.applyAt.less(CurrentDateTime()) }
                .groupBy(SchemaSubscribersTable.roleName,SchemaSubscribersTable.schemaName)
                .map {
                    SubscribeInfo(
                            roleName = it[SchemaSubscribersTable.roleName],
                            schemaName = it[SchemaSubscribersTable.schemaName],
                            currentVersion =it[/*How can I select currentVersion*/]
                    )
                }

    }

共有1个答案

艾俊悟
2023-03-14

您应该将别名存储在变量中,然后使用它从ResultRow获取值:

val version = SchemaVersionScheduleTable.version.max().alias("currentVersion")
...
.map {
    SubscribeInfo(
        roleName = it[SchemaSubscribersTable.roleName],
        schemaName = it[SchemaSubscribersTable.schemaName],
        currentVersion = it[version]
    )
}
 类似资料:
  • 我正在使用ktor应用程序开发一种静态编程语言,我使用暴露作为ORM。我有一个表,其中引用了另一个表。这种关系是多对一的。例如: 现在,当我尝试插入考勤表时,我不确定如何将插入映射到用户。我尝试了以下操作- 这会给出一个编译错误,即所需类型是

  • 问题内容: 我想了解MySQL中的某些特定行为。运行“ select @@ version”,我看到我的版本是5.6.34-log。 让我使用生成的表放置样本,以使其更易于重现: 正如标题所建议的那样,我最初搜索的是如何通过别名选择列,以便重用计算所得的字段,从而避免了冗长的查询。如文档中所述,大多数答案要么建议使用子查询,要么使用变量- 一种可读性差,而另一种则不能由自己的数据库开发人员来保证。

  • 主要内容:1.概述,2.doExportUrls,3. Protocol1.概述 Dubbo 服务暴露有两种方式 本地暴露,JVM 本地调用。配置如下: <dubbo:service scope=“local” /> <dubbo:service scope=“remote” /> 在不配置 scope 的情况下,默认两种方式都暴露。 2.doExportUrls 本地暴露服务的顺序图如下: 我们看到 ServiceConfig#export() 方法中,会在配置初始

  • 我已经通过dockerfile制作了一个图像,其中我通过“暴露22”行暴露了一个端口。 “sudo docker build-t mysql_服务器。” 在那之后,我发现我不需要这个端口。 如何关闭22端口? 编辑:@Adrian Mouat@seanmcl 图像是一个mysql。所以数据库中的数据都在我名为"cliff_mysql56"的容器中。如果我重建图像并运行它,我必须将我所有的数据从这个

  • 如何重新配置暴露的CIDR? 我知道 Openshift 3.1 可以在文件 /etc/origin/master/master-config.yaml 中 https://docs.openshift.com/container-platform/3.11/dev_guide/expose_service/expose_internal_ip_router.html,field networkC