make even less shitty
This commit is contained in:
@@ -42,25 +42,22 @@ 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 {
|
||||
return {}, false
|
||||
}
|
||||
continue
|
||||
// Can't convert attribute to bytes → skip this item
|
||||
return {}, false
|
||||
}
|
||||
|
||||
switch ks.key_type {
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user