Skip to content

Commit c469f9e

Browse files
committed
Fix some missing and deprecated API calls of Exposed and bump the project version since there are breaking changes
1 parent 46283f4 commit c469f9e

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

buildSrc/src/main/kotlin/VersionsAndDependencies.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import com.huanshankeji.CommonDependencies
22
import com.huanshankeji.CommonGradleClasspathDependencies
33
import com.huanshankeji.CommonVersions
44

5-
val projectVersion = "0.6.2-SNAPSHOT"
5+
val projectVersion = "0.7.0-SNAPSHOT"
66

77
// TODO remove Exposed's explicit version when migration to Exposed 1.0.0 is complete
88
// TODO Kotest 6 requires Java 11

exposed/src/main/kotlin/com/huanshankeji/exposed/Slice.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@ package com.huanshankeji.exposed
22

33
import com.huanshankeji.Untested
44
import org.jetbrains.exposed.sql.ColumnSet
5+
import org.jetbrains.exposed.sql.FieldSet
56

67
/**
78
* To simplify the SQL in some expression queries.
89
* For example `Dual.slice(exists(Table.emptySlice().select(op))).selectAll()` generates a SQL with no columns which is simpler.
910
*/
10-
@Deprecated("This causes \"java.lang.IllegalArgumentException: Can't prepare SELECT statement without columns or expressions to retrieve\" in the latest version of Exposed.")
11-
fun ColumnSet.emptySlice() =
12-
@Suppress("DEPRECATION_ERROR")
13-
slice(emptyList())
11+
@Deprecated(
12+
"This causes \"java.lang.IllegalArgumentException: Can't prepare SELECT statement without columns or expressions to retrieve\" in the latest version of Exposed. " +
13+
"Also, the original API in Exposed is removed."
14+
)
15+
fun ColumnSet.emptySlice(): FieldSet =
16+
throw NotImplementedError("The original API in Exposed is removed.")
1417

1518
@Untested
1619
fun ColumnSet.selectEmpty() =

exposed/src/main/kotlin/com/huanshankeji/exposed/Statements.kt

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package com.huanshankeji.exposed
55
import com.huanshankeji.InternalApi
66
import org.jetbrains.exposed.sql.*
77
import org.jetbrains.exposed.sql.statements.*
8+
import org.jetbrains.exposed.sql.statements.DeleteStatement
89

910
@InternalApi
1011
const val SELECT_DSL_DEPRECATION_MESSAGE =
@@ -19,8 +20,7 @@ const val SELECT_DSL_DEPRECATION_MESSAGE =
1920
ReplaceWith("selectAllStatement().where(where)")
2021
)
2122
fun FieldSet.selectStatement(where: WhereOp): Query =
22-
@Suppress("DEPRECATION_ERROR")
23-
select(where)
23+
throw NotImplementedError("The original API in Exposed is hidden.")
2424

2525
/**
2626
* Adapted from [org.jetbrains.exposed.sql.select].
@@ -30,8 +30,7 @@ fun FieldSet.selectStatement(where: WhereOp): Query =
3030
ReplaceWith("selectAllStatement().where(where)")
3131
)
3232
fun FieldSet.selectStatement(where: BuildWhere): Query =
33-
@Suppress("DEPRECATION_ERROR")
34-
select(where)
33+
throw NotImplementedError("The original API in Exposed is hidden.")
3534

3635
@Deprecated(
3736
SELECT_DSL_DEPRECATION_MESSAGE,
@@ -65,25 +64,28 @@ fun Table.deleteAllStatement() =
6564
DeleteStatement(this)
6665

6766
fun Table.deleteWhereStatement(
68-
op: WhereOp, isIgnore: Boolean = false, limit: Int? = null, offset: Long? = null
67+
where: WhereOp, isIgnore: Boolean = false, limit: Int? = null, offset: Long? = null
6968
): DeleteStatement =
70-
DeleteStatement(this, op, isIgnore, limit, offset)
69+
// TODO `offset` unused
70+
DeleteStatement(targetsSet = this, where, isIgnore, limit, emptyList())
7171

7272
/**
7373
* Adapted from [org.jetbrains.exposed.sql.deleteWhere].
7474
*/
7575
fun <T : Table> T.deleteWhereStatement(
76-
limit: Int? = null, offset: Long? = null, op: TableAwareWithSqlExpressionBuilderBuildWhere<T>
76+
limit: Int? = null, offset: Long? = null, where: TableAwareWithSqlExpressionBuilderBuildWhere<T>
7777
): DeleteStatement =
78-
DeleteStatement(this, op(SqlExpressionBuilder), false, limit, offset)
78+
// TODO `offset` unused
79+
DeleteStatement(targetsSet = this, where(SqlExpressionBuilder), false, limit, emptyList())
7980

8081
/**
8182
* Adapted from [org.jetbrains.exposed.sql.deleteWhere].
8283
*/
8384
fun <T : Table> T.deleteIgnoreWhereStatement(
84-
limit: Int? = null, offset: Long? = null, op: TableAwareWithSqlExpressionBuilderBuildWhere<T>
85+
limit: Int? = null, offset: Long? = null, where: TableAwareWithSqlExpressionBuilderBuildWhere<T>
8586
): DeleteStatement =
86-
DeleteStatement(this, op(SqlExpressionBuilder), true, limit, offset)
87+
// TODO `offset` unused
88+
DeleteStatement(targetsSet = this, where(SqlExpressionBuilder), true, limit, emptyList())
8789

8890
// to access the protected `arguments` in the super class
8991
class HelperInsertStatement<Key : Any>(table: Table, isIgnore: Boolean = false) :

0 commit comments

Comments
 (0)