Commit 0fb7774
feat(fr-035): present-key PATCH tristate — Kotlin port (completes all 5 ports)
Green the cross-port `update-explicit-null-clears` gate on Kotlin (both lanes),
completing FR-035 Part B across TS / Python / C# / Java / Kotlin. The generated
controller bound `@Valid @RequestBody dto: <Entity>` (a non-null-ctor data class),
so a partial PATCH omitting a @required field 400'd at Jackson binding and an
explicit null was a silent no-op. Rebind the update handler off the typed data
class onto the raw JSON tree — minimal inline, NOT the repo-delegation refactor:
- codegen-kotlin: the non-TPH `<Entity>Controller` constructor-injects an
`ObjectMapper` (only when it has settable scalar fields — a PK+object/jsonb-only
entity keeps a no-arg controller, so no unused-param `-Werror` break) and the
update handler binds `@RequestBody body: JsonNode`. Per body key: a non-object
body → 400; an explicit null on a @required field → 400; a present value binds
through the configured `ObjectMapper` (`treeToValue` with a `TypeReference` so
boxing / generics / inline enums survive) and per-field-dispatches into the
inline Exposed `update {}` (required → typed local; nullable → `if (n.isNull)
it[Table.col]=null else …`); an absent key is untouched; an effectively-empty
patch is a no-op read-back. Columns are qualified `it[Table.col]` (a field named
like the `body` param would otherwise shadow the column). A value whose JSON
shape can't bind → 400 (JsonMappingException), matching create, not a 500.
- reference server + KNOWN_GAPS + `PatchTristateEdgeCasesTest` (no-settable-field
controller emits no ObjectMapper/TypeReference; `PATCH {"name":{…}}` → 400).
Known gaps (KNOWN_GAPS.md, cross-port PATCH-4 follow-ups): (1) present-VALUE
constraint validation (@Size/@Pattern/@notblank) is not run on PATCH values (only
null-on-@required → 400) — matches C#/Java; TS/Python enforce it. (2) a
`field.string @dbColumnType:jsonb` open bag is a create-only column (kotlinx
JsonElement can't bind on the raw-JsonNode PATCH path without tripping the #179
open-bag guard) — PATCH leaves it untouched.
Gate green both Kotlin lanes (generated 23/0; reference 23/0 — the reference lane
occasionally flakes on PG-testcontainer readiness under load, a known
environmental issue, not a code failure); codegen-kotlin 48 reports / 0 failures;
jsonb 1/0 both, m2m 3/0 both, tph generated 5/0, enum/uuid run-tests green.
Generated Kotlin compiles under allWarningsAsErrors.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NGQ7oSuNcjhsMHWwZzhBwr1 parent 25bc2d2 commit 0fb7774
11 files changed
Lines changed: 302 additions & 46 deletions
File tree
- 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
- jsonb/generated
- m2m/generated
Lines changed: 22 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
Lines changed: 82 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
154 | 167 | | |
155 | 168 | | |
156 | 169 | | |
| |||
190 | 203 | | |
191 | 204 | | |
192 | 205 | | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
193 | 214 | | |
194 | 215 | | |
195 | 216 | | |
| |||
284 | 305 | | |
285 | 306 | | |
286 | 307 | | |
287 | | - | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
288 | 317 | | |
289 | 318 | | |
290 | 319 | | |
| |||
341 | 370 | | |
342 | 371 | | |
343 | 372 | | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
344 | 378 | | |
345 | 379 | | |
346 | 380 | | |
| |||
353 | 387 | | |
354 | 388 | | |
355 | 389 | | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
356 | 399 | | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
369 | 403 | | |
370 | | - | |
371 | | - | |
372 | | - | |
| 404 | + | |
373 | 405 | | |
374 | 406 | | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
381 | 441 | | |
382 | 442 | | |
383 | 443 | | |
| |||
Lines changed: 18 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
13 | 16 | | |
14 | 17 | | |
15 | 18 | | |
| |||
232 | 235 | | |
233 | 236 | | |
234 | 237 | | |
235 | | - | |
| 238 | + | |
236 | 239 | | |
237 | 240 | | |
238 | 241 | | |
| |||
280 | 283 | | |
281 | 284 | | |
282 | 285 | | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
291 | 297 | | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
292 | 301 | | |
293 | 302 | | |
294 | 303 | | |
| |||
Lines changed: 17 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
13 | 16 | | |
14 | 17 | | |
15 | 18 | | |
| |||
232 | 235 | | |
233 | 236 | | |
234 | 237 | | |
235 | | - | |
| 238 | + | |
236 | 239 | | |
237 | 240 | | |
238 | 241 | | |
| |||
280 | 283 | | |
281 | 284 | | |
282 | 285 | | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
291 | 296 | | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
292 | 300 | | |
293 | 301 | | |
294 | 302 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
200 | 206 | | |
201 | 207 | | |
202 | 208 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
| 92 | + | |
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| |||
0 commit comments