Skip to content

Commit 04c8fd3

Browse files
committed
db: Lazy construct parametrized query
1 parent 76e5439 commit 04c8fd3

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/core/db/traced/TracedPreparedStatement.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,15 @@ internal class TracedPreparedStatement internal constructor(
3939
}
4040

4141
private fun logTimings(result: Result<*>, duration: Duration) {
42-
val parametrizedQuery = parametrizedQuery.toSql()
43-
4442
if (logQueries) {
4543
logger.trace {
4644
val prefix = if (result.isSuccess) "Ran" else "Failed"
47-
"$prefix query in ${duration.toString(DurationUnit.MILLISECONDS, 2)}: $parametrizedQuery"
45+
"$prefix query in ${duration.toString(DurationUnit.MILLISECONDS, 2)}: ${parametrizedQuery.toSql()}"
4846
}
4947
}
5048
if (isQueryThresholdSet && duration > queryLogThreshold) {
5149
val prefix = if (result.isSuccess) "Ran" else "Failed"
52-
logger.warn { "$prefix query in ${duration.toString(DurationUnit.MILLISECONDS, 2)}: $parametrizedQuery" }
50+
logger.warn { "$prefix query in ${duration.toString(DurationUnit.MILLISECONDS, 2)}: ${parametrizedQuery.toSql()}" }
5351
}
5452
}
5553

@@ -310,4 +308,4 @@ internal class TracedPreparedStatement internal constructor(
310308
parametrizedQuery.addValue(parameterIndex, xmlObject)
311309
preparedStatement.setSQLXML(parameterIndex, xmlObject)
312310
}
313-
}
311+
}

0 commit comments

Comments
 (0)