Commit e0334cb
feat: typed value-object jsonb columns work end-to-end across all ports (#187)
* feat(jsonb): typed value-object jsonb columns work end-to-end across all ports
Typed @objectref value-object columns stored as jsonb (field.object
@storage:jsonb, single AND @isarray) now write+read correctly through every
port's persistence layer, gated by a new cross-port array-of-VO roundtrip
scenario. Three genuine, runtime-proven bugs fixed (the array-of-VO path was
untested everywhere, which is how they shipped):
Kotlin (codegen-kotlin) — REFACTOR to Jackson, drop decorative @serializable.
The port stamped kotlinx-serialization @serializable on every entity/value/
projection data class, and the typed jsonb column emitted
Json.encodeToString(VO.serializer(), ...) — which requires the kotlinx
compiler plugin, and the moment that plugin is enabled EVERY class with a
UUID/Instant/BigDecimal/URI/Inet/temporal field fails to compile (kotlinx has
no serializer for those java.* types). No consumer ever used kotlinx (all
Jackson); @serializable was decorative. Now: entity/value/projection classes
are plain data classes (Jackson-compatible); the typed jsonb + field.map
columns use a generated per-package MetaJsonbMapper.kt (Jackson ObjectMapper
with kotlinModule + JavaTimeModule) via Exposed's serialize/deserialize lambda
overload — no compiler plugin, matching Java(Gson)/C#(System.Text.Json)/TS/
Python. @serializable kept only on prompt payloads + enums (which genuinely
kotlinx-decode). New gate: a compile-without-the-plugin + Testcontainers-PG
roundtrip of a GENERATED typed-jsonb table (the missing gate that let the
broken form ship). Supersedes the unmerged fix/kotlin-exposed-jsonb-object-column.
C# (MetaObjects.Codegen) — array-of-VO jsonb was BROKEN (EF model finalization
threw "ICollection must be a non-interface reference type"). DbContextGenerator
now emits .OwnsMany (not .OwnsOne) when field.ResolvedIsArray(); a coupled
nullability defect (a non-null List initializer couldn't represent a NULL jsonb
column, conflating empty-[] with null) is fixed to mirror single-VO nullability.
Java (OMDB) — array-of-VO jsonb was a GAP (read threw "Expected BEGIN_OBJECT but
was BEGIN_ARRAY"). GenericSQLDriver.deserializeJsonb now branches on isArray
(TypeToken<List<VO>>) and parseField routes through setObjectArray; the
integration-tests RoundtripWriter authors a List<ValueObject> insert value.
Oracle: fixtures/persistence-conformance — a Label VO + a labels array-of-VO
jsonb field on AllTypes (regenerated canonical schema); roundtrip scenarios
exercise 2-element / empty-[] / 1-element arrays + the null case. TS was already
correct (27/0); it proved the fixture and disproved nothing.
All ports green: TS 27/0, C# 1402/0, Java OMDB 48/0 + persistence 24/0,
Kotlin 272/0 + integration 97/0 (all Testcontainers PG).
Co-Authored-By: Claude <noreply@anthropic.com>
* refactor(codegen-kotlin): dedup jsonb support-file emit + codec FQN (simplifier)
Quality-only follow-up from the 4-angle simplifier pass on the jsonb work
(reuse/simplification/efficiency/altitude — efficiency + altitude were clean,
C# + Java clean; all findings were Kotlin generator dedup):
- Extract emitSupportFile(pkg, outRoot, fileName, imports, block): the jsonb /
inet-uri / instant-tz per-package support-file emitters were three byte-identical
copies of the buildString + resolve + writeString scaffold. One helper now, each
emitter a one-liner.
- Use PackageMapping.toKotlin(target.name) instead of hand-splitting splitFqn then
rejoining "$p.$s" (byte-identical: toKotlin is ::→. on the whole FQN) at the two
new VO-FQN sites (buildObjectColumns decode + mapValueTypeFqn).
- Fold entityNeedsJacksonMapper's two field passes into one loop (the flattened
sub-field field.map check moves into the ObjectField branch — same behavior).
codegen-kotlin 272/0 — snapshots still byte-match (behavior-preserving).
Co-Authored-By: Claude <noreply@anthropic.com>
* no-mistakes(review): docs(kotlin): document Jackson jsonb deps, drop stale @serializable claims
* no-mistakes(test): fix Python jsonb write codec for array-of-VO roundtrip
* no-mistakes(document): docs: sync Kotlin Jackson jsonb + array-of-VO roundtrip gaps
* no-mistakes(document): docs(kotlin): fix stale test count and @serializable example
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 644d27f commit e0334cb
61 files changed
Lines changed: 932 additions & 151 deletions
File tree
- agent-context/skills
- metaobjects-audit/references
- metaobjects-codegen/references
- metaobjects-runtime-ui/references
- docs
- features
- ports
- fixtures/persistence-conformance
- canonical
- queries
- server
- csharp
- MetaObjects.Codegen.Tests
- MetaObjects.Codegen/Generators
- MetaObjects.IntegrationTests
- Generated
- Runner
- java
- codegen-kotlin
- src
- main/kotlin/com/metaobjects/generator/kotlin
- apidocs
- test
- kotlin/com/metaobjects/generator/kotlin
- resources/snapshots
- entity-with-bidirectional-fk/acme/blog
- entity-with-controller/acme/blog
- entity-with-enum/acme/game
- entity-with-fk/acme/blog
- entity-with-storage/acme/commerce
- entity-with-stored-proc/acme/ops
- entity-with-tph/acme/auth
- entity-with-view/acme/report
- single-entity-primitives/acme/demo
- integration-tests-kotlin/src/test/kotlin/com/metaobjects/integration/kotlin
- tables
- jsonb
- integration-tests/src/test/java/com/metaobjects/integration
- omdb/src
- main/java/com/metaobjects/manager/db/driver
- test
- java/com/metaobjects/manager/db
- resources
- python/src/metaobjects/runtime
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
12 | 16 | | |
13 | 17 | | |
| 18 | + | |
14 | 19 | | |
15 | 20 | | |
16 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
94 | 95 | | |
95 | 96 | | |
96 | 97 | | |
97 | | - | |
| 98 | + | |
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
| |||
Lines changed: 1 addition & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | 23 | | |
25 | 24 | | |
26 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
173 | | - | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
174 | 176 | | |
175 | 177 | | |
176 | 178 | | |
177 | 179 | | |
178 | 180 | | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | 181 | | |
183 | 182 | | |
184 | 183 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
145 | 144 | | |
146 | 145 | | |
147 | 146 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
| 97 | + | |
| 98 | + | |
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
| |||
270 | 271 | | |
271 | 272 | | |
272 | 273 | | |
273 | | - | |
| 274 | + | |
274 | 275 | | |
275 | 276 | | |
276 | 277 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
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 | + | |
| 61 | + | |
42 | 62 | | |
43 | 63 | | |
44 | 64 | | |
| |||
53 | 73 | | |
54 | 74 | | |
55 | 75 | | |
56 | | - | |
| 76 | + | |
57 | 77 | | |
58 | 78 | | |
59 | 79 | | |
| |||
139 | 159 | | |
140 | 160 | | |
141 | 161 | | |
142 | | - | |
143 | 162 | | |
144 | 163 | | |
145 | 164 | | |
| |||
0 commit comments