orangy / squash

SQL access DSL for Kotlin
265 stars 16 forks source link

Statement Dialect Extensions and JDBCTransaction.resultFor(statement) #36

Open codesplode opened 3 years ago

codesplode commented 3 years ago

First off, I hope the jetbrains team has had a wonderful holiday season and stayed safe & healthy during these times.

JDBCTransaction.resultFor() is a troubling method when creating Dialect Extensions, such as MySQL's extended insert statement.

This is because it performs logic to get the result of a statement, with no access to the generic type in Statement and is checks that depend on specific query classes (InsertValuesStatement, InsertQueryStatement, DeleteQueryStatement, etc.) It also throws an error for anything it does not match, making all new statement types fail by default. This means a query/statement dialect extension could not be made unless it extends an existing query type directly.

We have implemented the MySQL insert statement with multiple values lines by modifying the code to have a StatementWithoutResult flag interface that simply extends Statement in the JDBC module, and added that to the when statement in resultFor. This would work at some level for most queries, but we would like to ask @orangy for his input regarding how best to achieve this in Kotlin if there is a better way without flag interfaces or passing class references around as a contructor arg and which the jetbrains team would prefer, so that we may better our knowledge / reasoning.

We have also continued our development on squash quite a bit and would love to work with you when you surface @orangy !