-
Notifications
You must be signed in to change notification settings - Fork 751
refactor!: Rename IStatementBuilder interface and add executable converter #2562
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,11 @@ import org.jetbrains.exposed.v1.core.vendors.currentDialect | |
|
|
||
| /** Represents all the DSL methods available when building SQL statements. */ | ||
| @Suppress("TooManyFunctions") | ||
| @Deprecated( | ||
| message = "This interface has been renamed and will be removed in future releases.", | ||
| replaceWith = ReplaceWith("StatementBuilder", "org.jetbrains.exposed.v1.core.statements.StatementBuilder"), | ||
| level = DeprecationLevel.WARNING | ||
| ) | ||
| interface IStatementBuilder { | ||
| /** | ||
| * Represents the SQL statement that deletes only rows in a table that match the provided [op]. | ||
|
|
@@ -121,9 +126,9 @@ interface IStatementBuilder { | |
| fun <T : Table> T.insert( | ||
| selectQuery: AbstractQuery<*>, | ||
| columns: List<Column<*>>? = null | ||
| ): org.jetbrains.exposed.v1.core.statements.InsertSelectStatement { | ||
| ): InsertSelectStatement { | ||
| val columnsToReplace = columns ?: this.columns.filter { it.isValidIfAutoIncrement() } | ||
| return org.jetbrains.exposed.v1.core.statements.InsertSelectStatement(columnsToReplace, selectQuery, false) | ||
| return InsertSelectStatement(columnsToReplace, selectQuery, false) | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -140,9 +145,9 @@ interface IStatementBuilder { | |
| fun <T : Table> T.insertIgnore( | ||
| selectQuery: AbstractQuery<*>, | ||
| columns: List<Column<*>>? = null | ||
| ): org.jetbrains.exposed.v1.core.statements.InsertSelectStatement { | ||
| ): InsertSelectStatement { | ||
| val columnsToReplace = columns ?: this.columns.filter { it.isValidIfAutoIncrement() } | ||
| return org.jetbrains.exposed.v1.core.statements.InsertSelectStatement(columnsToReplace, selectQuery, true) | ||
| return InsertSelectStatement(columnsToReplace, selectQuery, true) | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -429,12 +434,3 @@ interface IStatementBuilder { | |
| private fun Column<*>.isValidIfAutoIncrement(): Boolean = | ||
| !columnType.isAutoInc || autoIncColumnType?.nextValExpression != null | ||
| } | ||
|
|
||
| /** Builder object for creating SQL statements. Made it private to avoid imports clash */ | ||
| @Suppress("ForbiddenComment") | ||
| // TODO: StatementBuilder -> StatementBuilderImpl, and IStatementBuilder -> StatementBuilder | ||
| private object StatementBuilder : IStatementBuilder | ||
|
|
||
| // TODO: add documentation for building statements without execution, like in the old DSL | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See PR #2563 |
||
| @Suppress("ForbiddenComment", "AnnotationSpacing") | ||
| fun <S> buildStatement(body: IStatementBuilder.() -> S): S = body(StatementBuilder) | ||
|
Comment on lines
-439
to
-440
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could not deprecate this, as lambda parameter would cause overload ambiguity error.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, just pointing out that the type parameter is not restricted to something like val x: String = buildStatement {
"hello world"
}Are we ok with this? Or is there a reason to not type it?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's fine |
||
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.
Let me know if either option would be better:
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.
It looks like many people use the
1.0.0-demo-xjust like the next versions of Exposed, so I'd say that it's better to keep it like this, and could be better to mark as deprecated and remove later. We still can do breaking changes, but if avoiding it is cheap, we could avoid it.