Repository navigation
Commit 01f7265
fix(kotlin): a required generated key blocked every create; conflicts 500'd; int-backed enum filters lied
Three defects in the generated Kotlin controller tier, found by building an
adopter estate's Kotlin backend from the published 8.0.5-rc.7 as the docs
describe - each with every in-repo lane green.
1. Create. The data class is also the create @RequestBody, and a @required
generated key made it a non-null ctor param with no default:
jackson-module-kotlin rejected every body that (correctly) omitted it, so
every create 400'd on the shape real models have (BaseEntity declares id
required). An increment key hid it - a missing Long binds 0 - a UUID
cannot. Behind it: the handler read a @generation: uuid key back from the
insert, which Exposed returns only for a value it inserted or an
autoIncrement column ("id is not in record set"). Now a server-owned-on-
create field (generated key, @autoset column) is nullable, default null,
no @field:NotNull - KotlinGenUtil.isServerOwnedOnCreate, mirroring Java's
SERVER_OWNED_ON_CREATE - and the handler mints a uuid key itself, as the
TS runtime does.
2. Conflicts. handleConstraintViolation was declared for RuntimeException;
Exposed raises ExposedSQLException, a CHECKED java.sql.SQLException, so it
never matched and every duplicate key / dangling reference was a 500. It
handles java.sql.SQLException too. Nothing had ever run it.
3. Int-backed enum filters. Every enum was compared as TEXT against the
member symbol; an @intValueMap column stores the integer, so eq/in matched
nothing and ne everything, with a 200. Now compared through the
enum-typed column (whose codec writes the integer).
Docs: docs/ports/kotlin.md's install block could not build a running app -
it now lists exposed-jdbc (runtime), exposed-java-time and exposed-json (the
tables import them), and says the controller needs KotlinRelationsGenerator
when the model has M:N. The config generator no longer claims a validator
runs when validatorEnabled=false.
Tests: UuidPkControllerRunTest now makes the uuid key @required, POSTs
without it (201, generated id) and POSTs a duplicate unique name (409);
EnumFilterControllerRunTest gains an int-backed enum (eq/ne/in/unknown).
Both failed before the fix. codegen-kotlin 394/0 (3 snapshots updated),
integration-tests-kotlin 161/0; the estate's Kotlin port 43/43 on this build.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EaGv4zNk4oT7FooD4eK5MD1 parent df72be5 commit 01f7265
11 files changed
Lines changed: 212 additions & 23 deletions
File tree
- docs/ports
- server/java
- codegen-kotlin/src
- main/kotlin/com/metaobjects/generator/kotlin
- test/resources/snapshots
- entity-with-controller/acme/blog
- entity-with-tph/acme/auth
- integration-tests-kotlin/src/test/kotlin/com/metaobjects/integration/kotlin/api/generated
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
305 | 345 | | |
306 | 346 | | |
307 | 347 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
42 | 61 | | |
43 | 62 | | |
44 | 63 | | |
| |||
87 | 106 | | |
88 | 107 | | |
89 | 108 | | |
90 | | - | |
| 109 | + | |
91 | 110 | | |
92 | 111 | | |
93 | 112 | | |
| |||
Lines changed: 11 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
201 | | - | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
202 | 211 | | |
203 | 212 | | |
204 | 213 | | |
| |||
208 | 217 | | |
209 | 218 | | |
210 | 219 | | |
211 | | - | |
| 220 | + | |
212 | 221 | | |
213 | 222 | | |
214 | 223 | | |
| |||
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
634 | 634 | | |
635 | 635 | | |
636 | 636 | | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
637 | 662 | | |
638 | 663 | | |
639 | 664 | | |
| |||
Lines changed: 11 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
67 | 74 | | |
68 | 75 | | |
69 | 76 | | |
| |||
0 commit comments