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
694 stars 85 forks source link

How do you plan to support different database platforms with the kotlin-jdsl library? #733

Closed Mina-1316 closed 2 months ago

Mina-1316 commented 3 months ago

Hello, I was about to use kotlin-jdsl with Room on Android(Of course I know that SQLite support isn't even on the roadmap yet), and a question came up, so I decided to write this issue.

According to the JSDL roadmap document, it says that it plans to support MySQL, Oracle, OpenSearch, etc. In this document, the sentence "Kotlin JDSL provides a MySQL-specific DSL that makes it easy to build MySQL queries." implies that additional DSL code is created specifically for MySQL. I am wondering if this means that the DSL currently in use will not be used as a common DSL. Are you planning to write different DSLs for each platform? Or will you use a common DSL and create multiple transpilers that convert the DSL into SQL strings for each platform?

I know it may be a bit early to ask since there doesn't seem to be a plan to support other platforms yet... but I wanted to ask for guidelines on areas where I can contribute related to this topic!

shouwn commented 3 months ago

First, thank you for your interest in Kotlin JDSL.

The current DSL provided by Kotlin JDSL is for JPQL and is not intended to be used across platforms. I'm thinking about providing a different DSL for each platform supported by the Kotlin JDSL.

The reason I want to make them different is because I'm not thinking about abstracting each platform specific language into a single language. What the Kotlin JDSL aims to do is to make it easy to use a particular language, and it aims to transfer the grammar of that language as it is.

In the implementation, Kotlin JDSL is divided into three main modules. They are dsl, query model and render. If you look at the code of Kotlin JDSL, you can see that under each of these three modules has a jpql module. For example, if I were working with mysql, I would create a new module called mysql under each of dsl, query-model, and render. And I would not allow the mysql and jpql modules to reference each other.

I intended to work on a DSL for MySQL this year, but I haven't gotten around to it this year due to the work of my current team. I probably won't be able to work on a DSL for MySQL until next year.

Personally, I'd like to see someone take over the main work on MySQL and coordinate the direction of the work through code reviews and Discord.

Mina-1316 commented 2 months ago

Thanks for the confirmation! I'll check more and contribute later if I can.