Thinking about using the Kotlin operator syntax #649
Replies: 1 comment
-
I've been thinking about the InfixThe whereOr(
( path(Employee::employeeId) ge 1L ) and ( path(Employee::employeeId) le 2L ),
( path(Employee::employeeId) ge 4L ) and ( path(Employee::employeeId) le 5L ),
) This causes interruptions in development. Because the operators you use later affect the operators before them. You may encounter a compile error in the middle of writing code, and you have to figure out which of the operators you used to add parentheses. Also, the more parentheses you have, the harder it is to understand the code. To help the Operator OverloadThe path(Employee::employeeId) + literalLong(1L) + literalLong(2L) // employee.employeeId + 1 + 2
path(Employee::employeeId) + ( literalLong(1L) + literalLong(2L) ) // employee.employeeId + 1 + 2 Since we can't provide parentheses as an operator, we can't make the parentheses the user used into an actual query. If we could, we would have to add parentheses to the result of each operator. However, as more parentheses are added, the actual query that is generated becomes harder to understand, and we have to generate more and more unnecessary parenthesis objects. I don't think |
Beta Was this translation helpful? Give feedback.
-
What do you think about using the kotlin operator syntax?
In some cases, but not all, infixes seem to lend themselves to a slightly more intuitive interpretation than prefixes.
If so, the above sentence could be rewritten as follows
Unlike QueryDSL, I think this is a sugar syntax that is only possible in Kotlin
If such syntaxes are added, it will be possible to write more intuitive and clearer syntaxes.
Item 1 (condition infix)
Before
After
Item 2 (operation infix)
Before
After
That's all working well.
Item 3 (case when infix)
Right now it's a dream, but
Why not further develop the domestic K-JDSL and reach 1k?
QueryDSL is a maintenance-only project with virtually no development.
I think Kotlin-JDSL is easier than jOOQ.
I want to let the JVM Kotlin camp know that there is KDSL.
Beta Was this translation helpful? Give feedback.
All reactions