-
Notifications
You must be signed in to change notification settings - Fork 667
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
Correct comparison of defaults for String type columns in PostgreSQL #1589
Correct comparison of defaults for String type columns in PostgreSQL #1589
Conversation
@@ -172,6 +172,7 @@ class JdbcDatabaseMetadataImpl(database: String, val metadata: DatabaseMetaData) | |||
is SQLServerDialect -> defaultValue.trim('(', ')', '\'') | |||
is OracleDialect -> defaultValue.trim().trim('\'') | |||
is MysqlDialect -> defaultValue.substringAfter("b'").trim('\'').trim() | |||
is PostgreSQLDialect -> defaultValue.trim() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like trim here and in default branch are wrong. With it it's impossible to set default value with whitespaces (like " ").
Could you please remove the trim and adjust your test by replacing empty string with whitespaces?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing this out, I'll add another test to reproduce and will fix this.
…d-missing-column-varchar-compare
…d-missing-column-varchar-compare
val text = text("text_column").default("") | ||
} | ||
|
||
// MySQL doesn't support default values on text columns, hence excluded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Tapac Would appreciate your input on that
detekt.yml
Outdated
@@ -1,7 +1,7 @@ | |||
# https://github.com/detekt/detekt/blob/main/detekt-core/src/main/resources/default-detekt-config.yml | |||
|
|||
build: | |||
maxIssues: 52 | |||
maxIssues: 200 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Tapac
I raised this as the current error count is 143, and I think Detekt errors should be addressed in a different PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May I ask you to merge master into the branch? Detekt issue was solved there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Tapac thank you, I'll do that
…1589) / Oracle threats '' as NULL, PSQL fails on comparing non-string defaults
Fixes #1587
Stripping the first single quote in PostgreSQL doesn't seem like a good strategy, since
'B'::text
is a valid default value.Branching with Text/Varchar seems necessary, because the default expression is always of
TextColumnType
, as it is mapped fromString
literal:Exposed/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/Op.kt
Line 567 in 9b561b0