Skip to content

Commit

Permalink
SQLServer metadata fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Tapac committed Jun 2, 2019
1 parent 8f0e702 commit 4362a41
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion exposed/src/main/kotlin/org/jetbrains/exposed/sql/Database.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,18 @@ class Database private constructor(val connector: () -> Connection) {
val supportsAlterTableWithAddColumn by lazy(LazyThreadSafetyMode.NONE) { metadata.supportsAlterTableWithAddColumn() }
val supportsMultipleResultSets by lazy(LazyThreadSafetyMode.NONE) { metadata.supportsMultipleResultSets() }

internal val identifierManager by lazy { IdentifierManager(metadata) }
internal val identifierManager by lazy {
// SQLServer driver closes metadata object when related connection close
if (dialect is SQLServerDialect && TransactionManager.currentOrNull() == null) {
val connection = connector()
try {
IdentifierManager(connection.metaData)
} finally {
connection.close()
}
} else
IdentifierManager(metadata)
}

internal class IdentifierManager(private val metadata: DatabaseMetaData) {
internal val quoteString = metadata.identifierQuoteString!!.trim()
Expand Down

0 comments on commit 4362a41

Please sign in to comment.