make even less shitty

This commit is contained in:
2026-02-16 09:26:21 -05:00
parent 29fe8a60c3
commit 26281bc16d
2 changed files with 6 additions and 11 deletions

View File

@@ -42,26 +42,23 @@ GSI_Key_Values :: struct {
}
// Extract GSI key values from an item based on the GSI's key schema.
// Returns ok=false if the required partition key attribute is missing (sparse index).
// Returns ok=false if ANY required key attribute is missing (sparse index).
// DynamoDB sparse index semantics: item must have ALL key attributes defined in the GSI schema.
gsi_extract_key_values :: proc(item: Item, gsi_key_schema: []Key_Schema_Element) -> (GSI_Key_Values, bool) {
result: GSI_Key_Values
for ks in gsi_key_schema {
attr, found := item[ks.attribute_name]
if !found {
if ks.key_type == .HASH {
return {}, false // PK missing → sparse, skip this GSI entry
}
continue // SK missing is OK, just no SK segment
// Any key attribute missing → sparse index, skip this item
return {}, false
}
raw, raw_ok := attr_value_to_bytes(attr)
if !raw_ok {
if ks.key_type == .HASH {
// Can't convert attribute to bytes → skip this item
return {}, false
}
continue
}
switch ks.key_type {
case .HASH:

View File

@@ -1,5 +1,3 @@
// update_item.odin — Storage layer UpdateItem operation
// This file lives in the dynamodb/ package alongside storage.odin
package dynamodb
import "core:strings"