From 33f0abd7e0bcaf40ac114bb15d61d39e31fbcaba Mon Sep 17 00:00:00 2001 From: Yongshun Shreck Ye Date: Thu, 14 Nov 2024 17:55:26 +0800 Subject: [PATCH] Run Code Cleanup with IntelliJ IDEA and revert some erroneous or unnecessary changes --- .../benchmark/PreparedSqlGenerationBenchmark.kt | 2 +- .../exposedvertxsqlclient/DatabaseClient.kt | 4 ++-- .../exposedvertxsqlclient/VertxSqlClients.kt | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/src/benchmarks/kotlin/com/huanshankeji/exposed/benchmark/PreparedSqlGenerationBenchmark.kt b/lib/src/benchmarks/kotlin/com/huanshankeji/exposed/benchmark/PreparedSqlGenerationBenchmark.kt index 3110a50..977bec2 100644 --- a/lib/src/benchmarks/kotlin/com/huanshankeji/exposed/benchmark/PreparedSqlGenerationBenchmark.kt +++ b/lib/src/benchmarks/kotlin/com/huanshankeji/exposed/benchmark/PreparedSqlGenerationBenchmark.kt @@ -16,7 +16,7 @@ import org.jetbrains.exposed.sql.transactions.transaction class PreparedSqlGenerationBenchmark : WithContainerizedDatabaseBenchmark() { enum class StatementEnum(val statement: Statement<*>) { SelectAll(VarcharTable.selectAll()), - SelectWhere(VarcharTable.select(VarcharTable.id eq 0L)), + SelectWhere(VarcharTable.selectAll().where(VarcharTable.id eq 0L)), Insert(VarcharTable.insertStatement { it[varcharColumn] = "string" }), Update(VarcharTable.updateStatement({ VarcharTable.id eq 0L }) { it[varcharColumn] = "string" diff --git a/lib/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/DatabaseClient.kt b/lib/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/DatabaseClient.kt index f66ac8a..b82985e 100644 --- a/lib/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/DatabaseClient.kt +++ b/lib/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/DatabaseClient.kt @@ -5,7 +5,7 @@ import com.huanshankeji.collections.singleOrNullIfEmpty import com.huanshankeji.exposedvertxsqlclient.ConnectionConfig.Socket import com.huanshankeji.exposedvertxsqlclient.ConnectionConfig.UnixDomainSocketWithPeerAuthentication import com.huanshankeji.exposedvertxsqlclient.sql.selectExpression -import com.huanshankeji.os.isOSLinux +import com.huanshankeji.os.isCurrentOsLinux import com.huanshankeji.vertx.kotlin.coroutines.coroutineToFuture import com.huanshankeji.vertx.kotlin.sqlclient.executeBatchAwaitForSqlResultSequence import io.vertx.core.Vertx @@ -529,7 +529,7 @@ fun createBetterPgPoolDatabaseClient( ) = createPgPoolDatabaseClient( vertx, - if (isOSLinux()) ConnectionType.UnixDomainSocketWithPeerAuthentication else ConnectionType.Socket, + if (isCurrentOsLinux()) ConnectionType.UnixDomainSocketWithPeerAuthentication else ConnectionType.Socket, localConnectionConfig, extraPgConnectOptions, poolOptions, exposedDatabase diff --git a/lib/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/VertxSqlClients.kt b/lib/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/VertxSqlClients.kt index f8feac9..6ec1cc3 100644 --- a/lib/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/VertxSqlClients.kt +++ b/lib/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/VertxSqlClients.kt @@ -2,7 +2,7 @@ package com.huanshankeji.exposedvertxsqlclient import com.huanshankeji.Untested import io.vertx.core.Vertx -import io.vertx.kotlin.coroutines.await +import io.vertx.kotlin.coroutines.coAwait import io.vertx.kotlin.sqlclient.poolOptionsOf import io.vertx.pgclient.PgConnectOptions import io.vertx.pgclient.PgConnection @@ -34,7 +34,7 @@ private val pgConnectionConnect: suspend (Vertx?, PgConnectOptions, Nothing?) -> */ suspend fun SqlConnection.executeSetRole(role: String) = - query("SET ROLE $role").execute().await() + query("SET ROLE $role").execute().coAwait() // TODO: use `ConnectionConfig` as the argument directly in all the following functions @@ -82,7 +82,7 @@ suspend fun createSocketPgConnection( createSocketGenericPgClient( vertx, host, port, database, user, password, extraPgConnectOptions, null ) { vertx, pgConnectOptions, _ -> - PgConnection.connect(vertx, pgConnectOptions).await() + PgConnection.connect(vertx, pgConnectOptions).coAwait() } @@ -121,7 +121,7 @@ suspend fun createUnixDomainSocketPgSqlClientAndSetRole( vertx, host, database, extraPgConnectOptions, poolOptions ).apply { // Is this done for all connections? - query("SET ROLE $role").execute().await() + query("SET ROLE $role").execute().coAwait() } fun createPeerAuthenticationUnixDomainSocketPgPool( @@ -144,7 +144,7 @@ fun createPeerAuthenticationUnixDomainSocketPgPoolAndSetRole( // TODO: are exceptions handled? it.executeSetRole(role) /** @see Pool.connectHandler */ - it.close().await() + it.close().coAwait() } } @@ -157,7 +157,7 @@ suspend fun createPeerAuthenticationUnixDomainSocketPgConnectionAndSetRole( createPeerAuthenticationUnixDomainSocketGenericPgClient( vertx, host, database, extraPgConnectOptions, null ) { vertx, pgConnectOptions, _ -> - PgConnection.connect(vertx, pgConnectOptions).await().apply { + PgConnection.connect(vertx, pgConnectOptions).coAwait().apply { executeSetRole(role) } }