Skip to content

Commit

Permalink
ORA-00972: identifier is too long. Oracle 11g #654
Browse files Browse the repository at this point in the history
  • Loading branch information
Tapac committed Oct 12, 2019
1 parent db06626 commit dc658ca
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ abstract class IdentifierManagerApi {
protected abstract fun dbKeywords() : List<String>
val keywords by lazy { ANSI_SQL_2003_KEYWORDS + VENDORS_KEYWORDS[currentDialect.name].orEmpty() + dbKeywords() }
protected abstract val extraNameCharacters : String
protected abstract val isOracle : Boolean
protected abstract val oracleVersion : OracleVersion
protected abstract val maxColumnNameLength : Int

protected enum class OracleVersion { Oracle11g, `Oracle12+`, NonOracle }

protected val identifierLengthLimit by lazy {
if (isOracle)
128
else
maxColumnNameLength.takeIf { it > 0 } ?: Int.MAX_VALUE
when(oracleVersion) {
OracleVersion.Oracle11g -> 30
OracleVersion.`Oracle12+` -> 128
else -> maxColumnNameLength.takeIf { it > 0 } ?: Int.MAX_VALUE
}
}

val checkedIdentities = object : LinkedHashMap<String, Boolean>(100) {
Expand All @@ -49,7 +53,7 @@ abstract class IdentifierManagerApi {
supportsMixedIdentifiers -> false
alreadyLower && isLowerCaseIdentifiers -> false
alreadyUpper && isUpperCaseIdentifiers -> false
isOracle -> false
oracleVersion != OracleVersion.NonOracle -> false
supportsMixedQuotedIdentifiers && (!alreadyLower && !alreadyUpper) -> true
else -> false
}
Expand All @@ -62,7 +66,7 @@ abstract class IdentifierManagerApi {
alreadyQuoted && isUpperCaseQuotedIdentifiers -> identity.toUpperCase()
alreadyQuoted && isLowerCaseQuotedIdentifiers -> identity.toLowerCase()
supportsMixedIdentifiers -> identity
isOracle -> identity.toUpperCase()
oracleVersion != OracleVersion.NonOracle -> identity.toUpperCase()
isUpperCaseIdentifiers -> identity.toUpperCase()
isLowerCaseIdentifiers -> identity.toLowerCase()
else -> identity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ internal class JdbcIdentifierManager(metadata: DatabaseMetaData) : IdentifierMan
private val _keywords = metadata.sqlKeywords.split(',')
override fun dbKeywords(): List<String> = _keywords
override val extraNameCharacters = metadata.extraNameCharacters!!
override val isOracle = metadata.databaseProductName == "Oracle"
override val oracleVersion = when {
metadata.databaseProductName != "Oracle" -> OracleVersion.NonOracle
metadata.databaseMajorVersion <= 11 -> OracleVersion.Oracle11g
else -> OracleVersion.`Oracle12+`
}
override val maxColumnNameLength: Int = metadata.maxColumnNameLength
}

0 comments on commit dc658ca

Please sign in to comment.