Ktorm v2.6 Release Notes

Release Date: 2019-11-02 // 3 months ago
  • πŸ‘Œ Support Running on Android Devices (#22)

    πŸ‘ Now, Ktorm is available for Android SQLite with the support of SQLDroid driver. And technically, any other JDBC driver is also supported (if you really need them running on Android).

    ⚑️ Update JVM Target to 1.6

    ⚑️ For maximum compatibility, we updated the compiler option -jvm-target to 1.6. This option is used to specify the version of the generated JVM bytecode. Moreover, to support running on Android and JDK 1.6, we added three SqlType implementations, they supports java.sql.Timestamp, java.sql.Date and java.sql.Time, because JSR-310 is not available on those platforms.

    πŸ‘Œ Support Multiple Bindings on One Column

    Now, we can bind a column to multiple properties by calling the bindTo or references functions continuously. In this way, when an entity object is retrieved from the database, the value of this column will be filled to each property it binds.

    interface Config : Entity\<Config\> { val key: Stringvar value1: Stringvar value2: String}object Configs : Table\<Config\>("t\_config") { val key by varchar("key").primaryKey().bindTo { it.key } val value by varchar("value").bindTo { it.value1 }.bindTo { it.value2 } }

    In the example above, we bound the value column to both value1 and value2, so the values of these two properties would be the same in an entity object obtained from the database.

    ⚑️ > Please note that multiple bindings are only available for query operations. When we are inserting or updating an entity, the first binding will prevail, and other bindings will be ignored.

    πŸ‘Œ Support Column Alias DSL (by @waluo, #37)

    Now, we can assign aliases to the selected columns of a query and use them in subsequent clauses such as group by and having, just like the as keyword in SQL. Here is an example. This query selects departments whose average salary is greater than 100, then returns the average salaries along with their department’s IDs.

    val deptId = Employees.departmentId.aliased("dept\_id")val salaryAvg = avg(Employees.salary).aliased("salary\_avg")Employees .select(deptId, salaryAvg) .groupBy(deptId) .having { salaryAvg greater 100.0 } .forEach { row -\>println("${row[deptId]}:${row[salaryAvg]}") }

    Generated SQL:

    select t\_employee.department\_id as dept\_id, avg(t\_employee.salary) as salary\_avg from t\_employee group by dept\_id having salary\_avg \> ?

    πŸ›  Other Optimizations and Bug Fixes

    • ♻️ Refactoring the implementation of QueryRowSet.
    • πŸ‘Œ Support SQL Server datetimeoffset data type.
    • Max/min aggregation functions' type arguments should be Comparable instead of Number (#46).

Previous changes from v2.5