Infrastructure
- Upgrade Kotlin version to 1.7.22, support latest JDK versions (min 8, max 19)
- Support Java 9 modular #421
Support SQL Window Functions, by @michaelfyc in #460
Ktorm now supports SQL window functions, here is an example:
database
.from(Employees)
.select(
Employees.name,
Employees.salary,
Employees.departmentId,
rank().over { partitionBy(Employees.departmentId).orderBy(Employees.salary.desc()) }
)
Generated SQL:
SELECT
"t_employee"."name" AS "t_employee_name",
"t_employee"."salary" AS "t_employee_salary",
"t_employee"."department_id" AS "t_employee_department_id",
RANK() OVER (PARTITION BY "t_employee"."department_id" ORDER BY "t_employee"."salary" DESC)
FROM "t_employee"
Support Case-When DSL, by @zuisong in #413
Ktorm now supports case-when DSL, for example:
database
.from(Employees)
.select(
Employees.id,
Employees.name,
CASE(Employees.sex).WHEN(1).THEN("male").WHEN(2).THEN("female").ELSE("unknown").END()
)
Generated SQL:
SELECT
"t_employee"."id" AS "t_employee_id",
"t_employee"."name" AS "t_employee_name",
CASE "t_employee"."sex" WHEN 1 THEN 'male' WHEN 2 THEN 'female' ELSE 'unknown' END
FROM "t_employee"
Other Optimizations & Bug Fixes
- Support
insert ... returning ...
for SQLite, by @2938137849 in #427 - Support SQL full join, by @KocproZ in #419
- Support MySQL & PostgreSQL
default
keyword for insert statements to use column default values, by @lookup-cat in #431 - Support SQL type casting syntax, by @svenallers in #415
- Rename
Query#totalRecords
toQuery#totalRecordsInAllPages
for better understandability, the origin name is now deprecated - Disable entity sequence for tables that doesn’t bound to entities, legacy usages will get a warning after 3.6.0
DefaultMethodHandler
to use the same class loader as the method's declaring class, by @brohacz in #471- Refactor
combineConditions
to avoid stack overflow errors #328 - Fix SQLite syntax error for UNIONs with subqueries #329
- Fix entity equality bug #466
- Fix bugs #386, #400, #405, #432, #433, #457
Break Changes
- Refactor SqlExpressionVisitor and its subtypes from classes to interfaces for better coding flexibility.
- Change SQL Server datetimeoffset's return type from
Column<microsoft.sql.DateTimeOffset>
toColumn<java.time.OffsetDateTime>