From 26281bc16dd6c666590e9b287e4cd58b25b4b7a3 Mon Sep 17 00:00:00 2001 From: biondizzle Date: Mon, 16 Feb 2026 09:26:21 -0500 Subject: [PATCH] make even less shitty --- dynamodb/gsi.odin | 15 ++++++--------- dynamodb/update_item.odin | 2 -- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/dynamodb/gsi.odin b/dynamodb/gsi.odin index e6fc0ad..9bace4f 100644 --- a/dynamodb/gsi.odin +++ b/dynamodb/gsi.odin @@ -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 { diff --git a/dynamodb/update_item.odin b/dynamodb/update_item.odin index ea02227..987272c 100644 --- a/dynamodb/update_item.odin +++ b/dynamodb/update_item.odin @@ -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"