line / kotlin-jdsl

Kotlin library that makes it easy to build and execute queries without generated metamodel
https://kotlin-jdsl.gitbook.io/docs/
Apache License 2.0
713 stars 88 forks source link

Implement JpqlSerializer for JpqlLike #375

Closed shouwn closed 1 year ago

shouwn commented 1 year ago

Backgrounds

Requirements

Contribution

jbl428 commented 1 year ago

@shouwn I have some question during implementing test for this. According to JPQL docs, Like expression has the following syntax.

string_expression [NOT] LIKE pattern_value [ESCAPE escape_character]

However, JpqlLike does not have property for escape character.

@Internal
data class JpqlLike internal constructor(
    val value: Expression<String>,
    val pattern: Expression<String>,
) : Predicate

I'm curious whether this is something that's missing or if you have plans to add it. And if you need to add it, I'm wondering whether it would be better to use stringLiteral from Expressions or to add a new character literals.

    @SinceJdsl("3.0.0")
    fun charactreLiteral(char: Char): Expression<Char> {
        return JpqlLiteral.CharLiteral(char)
    }
shouwn commented 1 year ago

@jbl428 Since I have no experience with ESCAPE, I didn't implement it because I didn't know how to actually add it.

Like you said, I looked it up and it seems that ESCAPE only allows one character, so it seems like a good idea to create a charLiteral() method.

If you don't mind, could you implement this? You don't need to implement tests of the DSL and QueryModel because I will implement these.

shouwn commented 1 year ago

It's okay if you don't implement it! I'd be happy if you just implemented JpqlLikeSerializer.