Commit 88e729d
fix(python): close attr-schema coverage gap — typed value_type for cross-port attrs
Python's field schema previously only registered @column, @storage, and
@objectref with a typed value_type, so the YAML desugar's D2 type-coercion
guard (ADR-0006) never fired for the other common field attrs. TS / C# /
Java already enforce these via their typed schemas — Python was the
outlier, silently accepting `maxLength: TRUE` etc.
Adds typed AttrSchema for every common field attr Python was missing:
@required boolean
@unique boolean
@default None (polymorphic — value-type follows owning
field's subtype; guard skips when value_type is None)
@maxlength int
@precision int
@scale int
@filterable boolean
@Sortable boolean
@sortableDefaultOrder string (allowed: asc, desc)
@autoset string (allowed: onCreate, onUpdate)
Mirrors server/typescript/.../core/field/field-schema.ts `commonFieldAttrs`
and server/csharp/.../Core/Field/FieldSchema.cs `CommonFieldAttrs`. The new
constants live in field_constants.py alongside their TS/C# peers (cross-
port parity). _FIELD_COMMON_ATTRS is now shared between field.* and
field.enum (was a separate hand-typed copy).
Also: AttrSchema.value_type is now Optional[str] to permit declaring a
"known but untyped" attr (e.g. @default), matching TS's `valueType?: string`
shape. The coercion guard already short-circuits when value_type is None.
Re-adds fixture error-yaml-coerced-bool-in-int that the YAML corpus
expansion (b2dc546) had to drop because Python's gap meant only 3/4 ports
fired. Now all four ports (TS, C#, Java, Python) emit
ERR_YAML_COERCION + ERR_BAD_ATTR_VALUE for `maxLength: TRUE`.
Verification:
Python 506 passed (was 505 baseline + 1 new fixture)
TS yaml-conformance 13/13
C# YamlConformance 13/13
Java YamlConformanceTest 13/13
TS metadata full 1226/1226
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent ad5c2cc commit 88e729d
5 files changed
Lines changed: 113 additions & 18 deletions
File tree
- fixtures/yaml-conformance/error-yaml-coerced-bool-in-int
- server/python/src/metaobjects
- meta/core/field
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
17 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
18 | 29 | | |
| 30 | + | |
19 | 31 | | |
20 | 32 | | |
| 33 | + | |
21 | 34 | | |
22 | 35 | | |
23 | 36 | | |
| |||
175 | 188 | | |
176 | 189 | | |
177 | 190 | | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
184 | 203 | | |
185 | | - | |
| 204 | + | |
186 | 205 | | |
187 | 206 | | |
188 | 207 | | |
| |||
192 | 211 | | |
193 | 212 | | |
194 | 213 | | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
199 | 239 | | |
200 | 240 | | |
201 | 241 | | |
| |||
206 | 246 | | |
207 | 247 | | |
208 | 248 | | |
209 | | - | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
210 | 253 | | |
211 | 254 | | |
212 | 255 | | |
213 | 256 | | |
214 | 257 | | |
215 | | - | |
| 258 | + | |
216 | 259 | | |
217 | 260 | | |
218 | 261 | | |
219 | 262 | | |
220 | 263 | | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | 264 | | |
225 | 265 | | |
226 | 266 | | |
| |||
Lines changed: 19 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
| 39 | + | |
| 40 | + | |
38 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
39 | 48 | | |
40 | | - | |
41 | 49 | | |
42 | 50 | | |
43 | 51 | | |
44 | 52 | | |
45 | 53 | | |
46 | 54 | | |
47 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
48 | 66 | | |
49 | 67 | | |
50 | 68 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
12 | 16 | | |
13 | 17 | | |
14 | 18 | | |
| |||
0 commit comments