Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
shouwn committed Oct 11, 2023
2 parents 5c015af + 7a1afca commit 7dc6b8a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 118 deletions.
48 changes: 44 additions & 4 deletions dsl/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/dsl/jpql/Jpql.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2485,7 +2485,17 @@ open class Jpql : JpqlDsl {
/**
* Creates a select clause in a select query.
*/
@SinceJdsl("3.0.0")
@Deprecated(
"""
The KClass parameter makes it confusing whether to specify the return type as generic or KClass
in the select function signature.
Therefore, Kotlin JDSL will remove select functions that accept the KClass parameter
to specify the return type as generic only.
Since these will be removed in the 3.0.0 release,
please use select functions that specify the return type via generic.
""",
ReplaceWith("select<T>(expr, *exprs)"),
)
fun <T : Any> select(
returnType: KClass<T>,
expr: Expressionable<*>,
Expand Down Expand Up @@ -2530,7 +2540,17 @@ open class Jpql : JpqlDsl {
/**
* Creates a select clause in a select query.
*/
@SinceJdsl("3.0.0")
@Deprecated(
"""
The KClass parameter makes it confusing whether to specify the return type as generic or KClass
in the select function signature.
Therefore, Kotlin JDSL will remove select functions that accept the KClass parameter
to specify the return type as generic only.
Since these will be removed in the 3.0.0 release,
please use select functions that specify the return type via generic.
""",
ReplaceWith("selectDistinct<T>(expr, *exprs)"),
)
fun <T : Any> selectDistinct(
returnType: KClass<T>,
expr: Expressionable<*>,
Expand Down Expand Up @@ -2566,7 +2586,17 @@ open class Jpql : JpqlDsl {
/**
* Creates a select clause with the DTO projection in a select query.
*/
@SinceJdsl("3.0.0")
@Deprecated(
"""
The KClass parameter makes it confusing whether to specify the return type as generic or KClass
in the select function signature.
Therefore, Kotlin JDSL will remove select functions that accept the KClass parameter
to specify the return type as generic only.
Since these will be removed in the 3.0.0 release,
please use select functions that specify the return type via generic.
""",
ReplaceWith("selectNew<T>(expr, *exprs)"),
)
fun <T : Any> selectNew(
returnType: KClass<T>,
expr: Expressionable<*>,
Expand Down Expand Up @@ -2607,7 +2637,17 @@ open class Jpql : JpqlDsl {
/**
* Creates a select clause with the DTO projection in a select query.
*/
@SinceJdsl("3.0.0")
@Deprecated(
"""
The KClass parameter makes it confusing whether to specify the return type as generic or KClass
in the select function signature.
Therefore, Kotlin JDSL will remove select functions that accept the KClass parameter
to specify the return type as generic only.
Since these will be removed in the 3.0.0 release,
please use select functions that specify the return type via generic.
""",
ReplaceWith("selectDistinctNew<T>(expr, *exprs)"),
)
fun <T : Any> selectDistinctNew(
returnType: KClass<T>,
expr: Expressionable<*>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,32 +69,6 @@ class SelectDslTest : WithAssertions {
assertThat(actual).isEqualTo(expected)
}

@Test
fun `select() with a class and expressions`() {
// when
val select = queryPart {
select(
View::class,
expression1,
expression2,
).from(
entity1,
)
}.toQuery()

val actual: SelectQuery<View> = select // for type check

// then
val expected = SelectQueries.selectQuery(
returnType = View::class,
distinct = false,
select = listOf(expression1, expression2),
from = listOf(entity1),
)

assertThat(actual).isEqualTo(expected)
}

@Test
fun `selectDistinct() with an expression`() {
// when
Expand Down Expand Up @@ -144,32 +118,6 @@ class SelectDslTest : WithAssertions {
assertThat(actual).isEqualTo(expected)
}

@Test
fun `selectDistinct() with a class and expressions`() {
// when
val select = queryPart {
selectDistinct(
View::class,
expression1,
expression2,
).from(
entity1,
)
}.toQuery()

val actual: SelectQuery<View> = select // for type check

// then
val expected = SelectQueries.selectQuery(
returnType = View::class,
distinct = true,
select = listOf(expression1, expression2),
from = listOf(entity1),
)

assertThat(actual).isEqualTo(expected)
}

@Test
fun `selectNew() with a generic type and expressions`() {
// when
Expand Down Expand Up @@ -200,37 +148,6 @@ class SelectDslTest : WithAssertions {
assertThat(actual).isEqualTo(expected)
}

@Test
fun `selectNew() with a class and expressions`() {
// when
val select = queryPart {
selectNew(
Dto::class,
expression1,
expression2,
).from(
entity1,
)
}.toQuery()

val actual: SelectQuery<Dto> = select // for type check

// then
val expected = SelectQueries.selectQuery(
returnType = Dto::class,
distinct = false,
select = listOf(
Expressions.new(
type = Dto::class,
args = listOf(expression1, expression2),
),
),
from = listOf(entity1),
)

assertThat(actual).isEqualTo(expected)
}

@Test
fun `selectDistinctNew() with a generic type and expressions`() {
// when
Expand Down Expand Up @@ -260,35 +177,4 @@ class SelectDslTest : WithAssertions {

assertThat(actual).isEqualTo(expected)
}

@Test
fun `selectDistinctNew() with a class and expressions`() {
// when
val select = queryPart {
selectDistinctNew(
Dto::class,
expression1,
expression2,
).from(
entity1,
)
}.toQuery()

val actual: SelectQuery<Dto> = select // for type check

// then
val expected = SelectQueries.selectQuery(
returnType = Dto::class,
distinct = true,
select = listOf(
Expressions.new(
type = Dto::class,
args = listOf(expression1, expression2),
),
),
from = listOf(entity1),
)

assertThat(actual).isEqualTo(expected)
}
}

0 comments on commit 7dc6b8a

Please sign in to comment.