make even less shitty
This commit is contained in:
@@ -42,26 +42,23 @@ GSI_Key_Values :: struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Extract GSI key values from an item based on the GSI's key schema.
|
// 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) {
|
gsi_extract_key_values :: proc(item: Item, gsi_key_schema: []Key_Schema_Element) -> (GSI_Key_Values, bool) {
|
||||||
result: GSI_Key_Values
|
result: GSI_Key_Values
|
||||||
|
|
||||||
for ks in gsi_key_schema {
|
for ks in gsi_key_schema {
|
||||||
attr, found := item[ks.attribute_name]
|
attr, found := item[ks.attribute_name]
|
||||||
if !found {
|
if !found {
|
||||||
if ks.key_type == .HASH {
|
// Any key attribute missing → sparse index, skip this item
|
||||||
return {}, false // PK missing → sparse, skip this GSI entry
|
return {}, false
|
||||||
}
|
|
||||||
continue // SK missing is OK, just no SK segment
|
|
||||||
}
|
}
|
||||||
|
|
||||||
raw, raw_ok := attr_value_to_bytes(attr)
|
raw, raw_ok := attr_value_to_bytes(attr)
|
||||||
if !raw_ok {
|
if !raw_ok {
|
||||||
if ks.key_type == .HASH {
|
// Can't convert attribute to bytes → skip this item
|
||||||
return {}, false
|
return {}, false
|
||||||
}
|
}
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ks.key_type {
|
switch ks.key_type {
|
||||||
case .HASH:
|
case .HASH:
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// update_item.odin — Storage layer UpdateItem operation
|
|
||||||
// This file lives in the dynamodb/ package alongside storage.odin
|
|
||||||
package dynamodb
|
package dynamodb
|
||||||
|
|
||||||
import "core:strings"
|
import "core:strings"
|
||||||
|
|||||||
Reference in New Issue
Block a user