-
-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
使用实体查询,框架会拼接字段名称为【表别名_字段】而遭到 ColumnNameChecker 字段名称过长拦截 #566
Comments
canmengqian
changed the title
使用实体查询,使用拼接后的字段【表别名_字段】遭到 ColumnNameChecker 字段名称过长拦截
使用实体查询,框架会拼接字段名称为【表别名_字段】而遭到 ColumnNameChecker 字段名称过长拦截
Jul 3, 2024
alias 短一点,单字母就可以,30 个字符的长度够用了 |
@vincentlauvlwj 目前项目里有些列名已经接近30个字符,拼上表别名就超了 😂😂😂 |
@canmengqian 你用的是什么数据库,一般数据库的长度限制都是 64 左右,30 比较少见 |
那也没办法,只能精简一下字段名,这里不校验的话,有些数据库会把超出长度的名字截断,会导致更隐蔽的 bug |
@vincentlauvlwj 用的Oracle数据库,是不是可以考虑不用将表别名纳入校验范围内,或者可以提供卸载拦截器的方式,或加上自定义拦截器接口 |
如果你能承担字段名截断的风险,可以用这个办法绕过校验 val database = Database.connect { ConnectionWrapper(dataSource.connection) }
class ConnectionWrapper(private val connection: Connection) : Connection by connection {
override fun getMetaData(): DatabaseMetaData {
return DatabaseMetaDataWrapper(connection.metaData)
}
}
class DatabaseMetaDataWrapper(private val databaseMetaData: DatabaseMetaData) : DatabaseMetaData by databaseMetaData {
override fun getMaxColumnNameLength(): Int {
return 0
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
通过元数据里的maxColumnNameLength 和拼接后的字段 来进行比较长度,导致因为拼接了表别名的原因遭到ColumnNameChecker 拦截
The text was updated successfully, but these errors were encountered: