From ae60ac98c6e1024b18952131b00f163cf271e123 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 23 Oct 2023 16:53:37 +0000 Subject: [PATCH 01/10] chore(deps): update actions/setup-node action to v4 --- .github/workflows/lint.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index cacc6c951..858a7f3bb 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -18,7 +18,7 @@ jobs: with: fetch-depth: 0 - name: Setup Node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 16.x - name: Install dependencies From 63381a87caa5c68899fc552f8c45694bb9ef8e02 Mon Sep 17 00:00:00 2001 From: waahhh Date: Tue, 24 Oct 2023 03:06:39 +0900 Subject: [PATCH 02/10] feat(query-model): add JpqlUpper --- .../querymodel/jpql/expression/impl/JpqlUpper.kt | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 query-model/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/impl/JpqlUpper.kt diff --git a/query-model/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/impl/JpqlUpper.kt b/query-model/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/impl/JpqlUpper.kt new file mode 100644 index 000000000..20471cb16 --- /dev/null +++ b/query-model/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/impl/JpqlUpper.kt @@ -0,0 +1,9 @@ +package com.linecorp.kotlinjdsl.querymodel.jpql.expression.impl + +import com.linecorp.kotlinjdsl.Internal +import com.linecorp.kotlinjdsl.querymodel.jpql.expression.Expression + +@Internal +data class JpqlUpper internal constructor( + val string: Expression, +) : Expression From 037d146a9e2df64ff76ad0bcef2e3209ffdae1f8 Mon Sep 17 00:00:00 2001 From: waahhh Date: Tue, 24 Oct 2023 03:12:28 +0900 Subject: [PATCH 03/10] feat(query-model): add upper method to Expressions --- .../kotlinjdsl/querymodel/jpql/expression/Expressions.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/query-model/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/Expressions.kt b/query-model/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/Expressions.kt index 8c426e982..afc7b5de2 100644 --- a/query-model/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/Expressions.kt +++ b/query-model/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/Expressions.kt @@ -29,6 +29,7 @@ import com.linecorp.kotlinjdsl.querymodel.jpql.expression.impl.JpqlPlus import com.linecorp.kotlinjdsl.querymodel.jpql.expression.impl.JpqlSubquery import com.linecorp.kotlinjdsl.querymodel.jpql.expression.impl.JpqlSum import com.linecorp.kotlinjdsl.querymodel.jpql.expression.impl.JpqlTimes +import com.linecorp.kotlinjdsl.querymodel.jpql.expression.impl.JpqlUpper import com.linecorp.kotlinjdsl.querymodel.jpql.expression.impl.JpqlValue import com.linecorp.kotlinjdsl.querymodel.jpql.path.Path import com.linecorp.kotlinjdsl.querymodel.jpql.predicate.Predicate @@ -414,6 +415,14 @@ object Expressions { return JpqlPathType(path) } + /** + * Creates an expression that represents the string in uppercase. + */ + @SinceJdsl("3.0.0") + fun upper(string: Expression): Expression { + return JpqlUpper(string) + } + /** * Creates an expression that represents the length of the string as an integer. */ From bc9bd0f8c5999d18e92b5c2dc1c82dd6709364a7 Mon Sep 17 00:00:00 2001 From: waahhh Date: Tue, 24 Oct 2023 03:14:26 +0900 Subject: [PATCH 04/10] test(query-model): for upper method in Expressions --- .../querymodel/jpql/expression/ExpressionsTest.kt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/query-model/jpql/src/test/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/ExpressionsTest.kt b/query-model/jpql/src/test/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/ExpressionsTest.kt index 37b2ce99a..bace98a9c 100644 --- a/query-model/jpql/src/test/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/ExpressionsTest.kt +++ b/query-model/jpql/src/test/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/ExpressionsTest.kt @@ -31,6 +31,7 @@ import com.linecorp.kotlinjdsl.querymodel.jpql.expression.impl.JpqlPlus import com.linecorp.kotlinjdsl.querymodel.jpql.expression.impl.JpqlSubquery import com.linecorp.kotlinjdsl.querymodel.jpql.expression.impl.JpqlSum import com.linecorp.kotlinjdsl.querymodel.jpql.expression.impl.JpqlTimes +import com.linecorp.kotlinjdsl.querymodel.jpql.expression.impl.JpqlUpper import com.linecorp.kotlinjdsl.querymodel.jpql.expression.impl.JpqlValue import com.linecorp.kotlinjdsl.querymodel.jpql.path.Paths import com.linecorp.kotlinjdsl.querymodel.jpql.predicate.Predicates @@ -598,6 +599,19 @@ class ExpressionsTest : WithAssertions { assertThat(actual).isEqualTo(expected) } + @Test + fun upper() { + // when + val actual = Expressions.upper(stringExpression1) + + // then + val expected = JpqlUpper( + stringExpression1, + ) + + assertThat(actual).isEqualTo(expected) + } + @Test fun length() { // when From 31e7013650ebb6245ff897878129463c8fe330e6 Mon Sep 17 00:00:00 2001 From: waahhh Date: Tue, 24 Oct 2023 03:17:45 +0900 Subject: [PATCH 05/10] feat(render): add JpqlUpperSerializer --- .../render/jpql/JpqlRenderContext.kt | 2 ++ .../serializer/impl/JpqlUpperSerializer.kt | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 render/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/render/jpql/serializer/impl/JpqlUpperSerializer.kt diff --git a/render/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/render/jpql/JpqlRenderContext.kt b/render/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/render/jpql/JpqlRenderContext.kt index 1d035a1fa..10b7fcd67 100644 --- a/render/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/render/jpql/JpqlRenderContext.kt +++ b/render/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/render/jpql/JpqlRenderContext.kt @@ -94,6 +94,7 @@ import com.linecorp.kotlinjdsl.render.jpql.serializer.impl.JpqlSubquerySerialize import com.linecorp.kotlinjdsl.render.jpql.serializer.impl.JpqlSumSerializer import com.linecorp.kotlinjdsl.render.jpql.serializer.impl.JpqlTimesSerializer import com.linecorp.kotlinjdsl.render.jpql.serializer.impl.JpqlUpdateQuerySerializer +import com.linecorp.kotlinjdsl.render.jpql.serializer.impl.JpqlUpperSerializer import com.linecorp.kotlinjdsl.render.jpql.serializer.impl.JpqlValueSerializer /** @@ -327,6 +328,7 @@ private class DefaultModule : JpqlRenderModule { JpqlSumSerializer(), JpqlTimesSerializer(), JpqlUpdateQuerySerializer(), + JpqlUpperSerializer(), JpqlValueSerializer(), ) } diff --git a/render/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/render/jpql/serializer/impl/JpqlUpperSerializer.kt b/render/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/render/jpql/serializer/impl/JpqlUpperSerializer.kt new file mode 100644 index 000000000..5fd1da5b0 --- /dev/null +++ b/render/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/render/jpql/serializer/impl/JpqlUpperSerializer.kt @@ -0,0 +1,26 @@ +package com.linecorp.kotlinjdsl.render.jpql.serializer.impl + +import com.linecorp.kotlinjdsl.Internal +import com.linecorp.kotlinjdsl.querymodel.jpql.expression.impl.JpqlUpper +import com.linecorp.kotlinjdsl.render.RenderContext +import com.linecorp.kotlinjdsl.render.jpql.serializer.JpqlRenderSerializer +import com.linecorp.kotlinjdsl.render.jpql.serializer.JpqlSerializer +import com.linecorp.kotlinjdsl.render.jpql.writer.JpqlWriter +import kotlin.reflect.KClass + +@Internal +class JpqlUpperSerializer : JpqlSerializer { + override fun handledType(): KClass { + return JpqlUpper::class + } + + override fun serialize(part: JpqlUpper, writer: JpqlWriter, context: RenderContext) { + val delegate = context.getValue(JpqlRenderSerializer) + + writer.write("UPPER") + + writer.writeParentheses { + delegate.serialize(part.string, writer, context) + } + } +} From 40268b584c4117f869421616c3a61fdb0321e375 Mon Sep 17 00:00:00 2001 From: waahhh Date: Tue, 24 Oct 2023 03:28:18 +0900 Subject: [PATCH 06/10] test(render): for JpqlUpperSerializer --- .../impl/JpqlUpperSerializerTest.kt | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 render/jpql/src/test/kotlin/com/linecorp/kotlinjdsl/render/jpql/serializer/impl/JpqlUpperSerializerTest.kt diff --git a/render/jpql/src/test/kotlin/com/linecorp/kotlinjdsl/render/jpql/serializer/impl/JpqlUpperSerializerTest.kt b/render/jpql/src/test/kotlin/com/linecorp/kotlinjdsl/render/jpql/serializer/impl/JpqlUpperSerializerTest.kt new file mode 100644 index 000000000..41ae2511a --- /dev/null +++ b/render/jpql/src/test/kotlin/com/linecorp/kotlinjdsl/render/jpql/serializer/impl/JpqlUpperSerializerTest.kt @@ -0,0 +1,53 @@ +package com.linecorp.kotlinjdsl.render.jpql.serializer.impl + +import com.linecorp.kotlinjdsl.querymodel.jpql.expression.Expressions +import com.linecorp.kotlinjdsl.querymodel.jpql.expression.impl.JpqlUpper +import com.linecorp.kotlinjdsl.render.TestRenderContext +import com.linecorp.kotlinjdsl.render.jpql.serializer.JpqlRenderSerializer +import com.linecorp.kotlinjdsl.render.jpql.serializer.JpqlSerializerTest +import com.linecorp.kotlinjdsl.render.jpql.writer.JpqlWriter +import io.mockk.impl.annotations.MockK +import io.mockk.verifySequence +import org.assertj.core.api.WithAssertions +import org.junit.jupiter.api.Test + +@JpqlSerializerTest +class JpqlUpperSerializerTest : WithAssertions { + private val sut = JpqlUpperSerializer() + + @MockK + private lateinit var writer: JpqlWriter + + @MockK + private lateinit var serializer: JpqlRenderSerializer + + private val stringExpression1 = Expressions.value("string1") + + @Test + fun handledType() { + // when + val actual = sut.handledType() + + // then + assertThat(actual).isEqualTo(JpqlUpper::class) + } + + @Test + fun serialize() { + // given + val part = Expressions.upper( + stringExpression1, + ) + val context = TestRenderContext(serializer) + + // when + sut.serialize(part as JpqlUpper, writer, context) + + // then + verifySequence { + writer.write("UPPER") + writer.writeParentheses(any()) + serializer.serialize(stringExpression1, writer, context) + } + } +} From 4abd4e0deba077cb652ccbca6527f14f6e67b569 Mon Sep 17 00:00:00 2001 From: waahhh Date: Tue, 24 Oct 2023 03:31:09 +0900 Subject: [PATCH 07/10] feat(dsl): add dsl for upper function support --- .../com/linecorp/kotlinjdsl/dsl/jpql/Jpql.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/dsl/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/dsl/jpql/Jpql.kt b/dsl/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/dsl/jpql/Jpql.kt index cc13dd2d2..cfb415da5 100644 --- a/dsl/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/dsl/jpql/Jpql.kt +++ b/dsl/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/dsl/jpql/Jpql.kt @@ -1042,6 +1042,22 @@ open class Jpql : JpqlDsl { return Expressions.type(path.toPath()) } + /** + * Creates an expression that represents the string in uppercase. + */ + @SinceJdsl("3.0.0") + fun upper(string: String): Expression { + return Expressions.upper(Expressions.value(string)) + } + + /** + * Creates an expression that represents the string in uppercase. + */ + @SinceJdsl("3.0.0") + fun upper(string: Expressionable): Expression { + return Expressions.upper(string.toExpression()) + } + /** * Creates an expression that represents the length of the string as an integer. */ From 0b01c6df18ae553b8567ea214a413cfca6e5b6b9 Mon Sep 17 00:00:00 2001 From: waahhh Date: Tue, 24 Oct 2023 03:34:30 +0900 Subject: [PATCH 08/10] test(dsl): for UpperDsl --- .../dsl/jpql/expression/UpperDslTest.kt | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 dsl/jpql/src/test/kotlin/com/linecorp/kotlinjdsl/dsl/jpql/expression/UpperDslTest.kt diff --git a/dsl/jpql/src/test/kotlin/com/linecorp/kotlinjdsl/dsl/jpql/expression/UpperDslTest.kt b/dsl/jpql/src/test/kotlin/com/linecorp/kotlinjdsl/dsl/jpql/expression/UpperDslTest.kt new file mode 100644 index 000000000..ac2ea630d --- /dev/null +++ b/dsl/jpql/src/test/kotlin/com/linecorp/kotlinjdsl/dsl/jpql/expression/UpperDslTest.kt @@ -0,0 +1,47 @@ +package com.linecorp.kotlinjdsl.dsl.jpql.expression + +import com.linecorp.kotlinjdsl.dsl.jpql.queryPart +import com.linecorp.kotlinjdsl.querymodel.jpql.expression.Expression +import com.linecorp.kotlinjdsl.querymodel.jpql.expression.Expressions +import org.assertj.core.api.WithAssertions +import org.junit.jupiter.api.Test + +class UpperDslTest : WithAssertions { + private val string1 = "string1" + + private val stringExpression1 = Expressions.value("string1") + + @Test + fun `upper() with a string`() { + // when + val expression = queryPart { + upper(string1) + }.toExpression() + + val actual: Expression = expression // for type check + + // then + val expected = Expressions.upper( + Expressions.value(string1), + ) + + assertThat(actual).isEqualTo(expected) + } + + @Test + fun `upper() with a string expression`() { + // when + val expression = queryPart { + upper(stringExpression1) + }.toExpression() + + val actual: Expression = expression // for type check + + // then + val expected = Expressions.upper( + stringExpression1, + ) + + assertThat(actual).isEqualTo(expected) + } +} From 2832ae4fd3c635c98537720017a3ac7f0b151afe Mon Sep 17 00:00:00 2001 From: "jonghyon.s" Date: Tue, 24 Oct 2023 10:05:34 +0900 Subject: [PATCH 09/10] style: rename parameter of upper --- .../kotlin/com/linecorp/kotlinjdsl/dsl/jpql/Jpql.kt | 10 +++++----- .../querymodel/jpql/expression/Expressions.kt | 4 ++-- .../querymodel/jpql/expression/impl/JpqlUpper.kt | 2 +- .../querymodel/jpql/expression/ExpressionsTest.kt | 2 +- .../render/jpql/serializer/impl/JpqlUpperSerializer.kt | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dsl/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/dsl/jpql/Jpql.kt b/dsl/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/dsl/jpql/Jpql.kt index 7aa26ab76..af755fd75 100644 --- a/dsl/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/dsl/jpql/Jpql.kt +++ b/dsl/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/dsl/jpql/Jpql.kt @@ -1046,18 +1046,18 @@ open class Jpql : JpqlDsl { * Creates an expression that represents the string in uppercase. */ @SinceJdsl("3.0.0") - fun upper(string: String): Expression { - return Expressions.upper(Expressions.value(string)) + fun upper(value: String): Expression { + return Expressions.upper(Expressions.value(value)) } /** * Creates an expression that represents the string in uppercase. */ @SinceJdsl("3.0.0") - fun upper(string: Expressionable): Expression { - return Expressions.upper(string.toExpression()) + fun upper(value: Expressionable): Expression { + return Expressions.upper(value.toExpression()) } - + /** * Creates an expression that represents the string in lowercase. */ diff --git a/query-model/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/Expressions.kt b/query-model/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/Expressions.kt index 0a0d0abaa..d8ce36e44 100644 --- a/query-model/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/Expressions.kt +++ b/query-model/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/Expressions.kt @@ -420,8 +420,8 @@ object Expressions { * Creates an expression that represents the string in uppercase. */ @SinceJdsl("3.0.0") - fun upper(string: Expression): Expression { - return JpqlUpper(string) + fun upper(value: Expression): Expression { + return JpqlUpper(value) } /** diff --git a/query-model/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/impl/JpqlUpper.kt b/query-model/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/impl/JpqlUpper.kt index 20471cb16..4286925cf 100644 --- a/query-model/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/impl/JpqlUpper.kt +++ b/query-model/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/impl/JpqlUpper.kt @@ -5,5 +5,5 @@ import com.linecorp.kotlinjdsl.querymodel.jpql.expression.Expression @Internal data class JpqlUpper internal constructor( - val string: Expression, + val value: Expression, ) : Expression diff --git a/query-model/jpql/src/test/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/ExpressionsTest.kt b/query-model/jpql/src/test/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/ExpressionsTest.kt index 97295a0c3..980d7c71a 100644 --- a/query-model/jpql/src/test/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/ExpressionsTest.kt +++ b/query-model/jpql/src/test/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/ExpressionsTest.kt @@ -612,7 +612,7 @@ class ExpressionsTest : WithAssertions { assertThat(actual).isEqualTo(expected) } - + @Test fun lower() { // when diff --git a/render/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/render/jpql/serializer/impl/JpqlUpperSerializer.kt b/render/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/render/jpql/serializer/impl/JpqlUpperSerializer.kt index 5fd1da5b0..6dd8e5895 100644 --- a/render/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/render/jpql/serializer/impl/JpqlUpperSerializer.kt +++ b/render/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/render/jpql/serializer/impl/JpqlUpperSerializer.kt @@ -20,7 +20,7 @@ class JpqlUpperSerializer : JpqlSerializer { writer.write("UPPER") writer.writeParentheses { - delegate.serialize(part.string, writer, context) + delegate.serialize(part.value, writer, context) } } } From 3b01d08e9341c200f5196729d31d6e337faaf042 Mon Sep 17 00:00:00 2001 From: "jonghyon.s" Date: Tue, 24 Oct 2023 10:07:02 +0900 Subject: [PATCH 10/10] docs: support upper function --- docs/en/jpql-with-kotlin-jdsl/expressions.md | 2 +- docs/ko/jpql-with-kotlin-jdsl/expressions.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/jpql-with-kotlin-jdsl/expressions.md b/docs/en/jpql-with-kotlin-jdsl/expressions.md index 6dd359985..8aaba5a37 100644 --- a/docs/en/jpql-with-kotlin-jdsl/expressions.md +++ b/docs/en/jpql-with-kotlin-jdsl/expressions.md @@ -197,7 +197,7 @@ Kotlin JDSL provides functions to support built-in functions in JPA. | SUBSTRING | not yet | | TRIM | not yet | | LOWER | support | -| UPPER | not yet | +| UPPER | support | | LENGTH | support | | LOCATE | support | diff --git a/docs/ko/jpql-with-kotlin-jdsl/expressions.md b/docs/ko/jpql-with-kotlin-jdsl/expressions.md index 4fb5c9875..6b3da9f8e 100644 --- a/docs/ko/jpql-with-kotlin-jdsl/expressions.md +++ b/docs/ko/jpql-with-kotlin-jdsl/expressions.md @@ -196,7 +196,7 @@ Kotlin JDSL은 JPA에서 제공하는 여러 함수들을 지원하기 위함 | SUBSTRING | not yet | | TRIM | not yet | | LOWER | support | -| UPPER | not yet | +| UPPER | support | | LENGTH | support | | LOCATE | support |