Repository navigation
fix(value): validate map keys and values against the declared types - #56
pratik-saptarshi wants to merge 2 commits into
Conversation
…ld type Restacked onto main at 0bbf510 after parent PR LadybugDB#47 merged. This single commit carries the reviewed residual of d7c29d1 (PR LadybugDB#55) unchanged: per-file added/removed line multisets proven byte-identical to the saved residual before pushing.
Restacked onto the restacked PR LadybugDB#55 branch (7f3880d) after parent PR LadybugDB#47 merged. This single commit carries the reviewed residual of 0645721 (PR LadybugDB#56) unchanged: per-file added/removed line multisets proven byte-identical to the saved residual before pushing.
0645721 to
764c210
Compare
|
Restack note: this branch was rebuilt after PR #47 merged into main (merge commit — Musebot-Astro |
|
Correction to the restack note above: the base change described there did not take effect. GitHub rejected the retarget because a pull request's base branch must exist in this repository, and PR #55's branch is in the fork, so this PR's base remains — Musebot-Astro |
Addresses #51. Stacked on #50 (which is itself stacked on #47): this branch is based on the head of the #50 branch (
fix/nested-type-validation-c3), so until #47 and #50 merge the diff includes their commits. The new work is the top two commits, and this PR reuses theConversionError::TypeMismatcherror and the sharedcheck_nested_typehelper introduced there.Problem
Value::Map((key_type, value_type), pairs)repeated the unchecked pattern from #50: pairs were built as key/value structs under the declared types without checking the payload, and the engine reinterpreted keys and values at the declared width at storage time:MAP(STRING, INT32)with anInt64(4294967301)value: insert succeeded, stored value read back asInt32(5).MAP(INT32, STRING)withInt64(4294967301)andInt64(5)keys: insert succeeded, both keys were stored asInt32(5)— the stored map held duplicate keys, with no deduplication.Fix
Every key is validated against the declared key type and every value against the declared value type before conversion, returning
ConversionError::TypeMismatchon a mismatch — the same rule and error as the list/array validation in #50.Tests
map_key_and_value_type_mismatch_returns_error— both reproductions above fail the conversion.map_mismatched_types_fail_insert— the value-mismatch reproduction now fails at execute time instead of storing a truncated value.Full library test suite: 197 passed, 0 failed.
— Musebot-Astro