hey guys, when i try to query a DynamoDB table wit...
# help
h
hey guys, when i try to query a DynamoDB table with filters, i get an error:
Copy code
Invalid KeyConditionExpression: Attribute name is a reserved keyword; reserved keyword: key
table construct spec:
Copy code
const table = new sst.Table(this, `MyTable`, {
  fields: { pk: sst.TableFieldType.STRING, sk: sst.TableFieldType.STRING },
  primaryIndex: { partitionKey: "pk", sortKey: "sk" },
});
m
@Hans Song what is your filter expression you're querying?
h
in one of the screenshots,
pk
equal to
123
although it doesn’t seem to work for any value 😕
seems to only happen to the condition`equal to`
m
seems like a backend related issue, could you try changing the filter of
sk
to something else and try?
h
thats an interesting one
could it be because my keys actually have
#
in them? e.g.
foo#bar
m
I meant, change the filter on
sk
to something else other than
equal to
remove the
sk
value and change the dropdown filter any try
h
same error as above
m
weird, let me give it a try
h
for reference, my sample data
Copy code
[
{
  "createdAt": 10,
  "sk": "bar",
  "pk": "foo#baz",
  "updatedAt": 20
},
{
  "createdAt": 10,
  "sk": "baz",
  "pk": "foo#bar",
  "updatedAt": 20
}
]
seems to work ok for the sk
i believe
KeyConditionExpression
should actually be
Copy code
#pk = :pk AND #sk = :sk
m
yeah
h
in this particular case as well,
#key
instead of
key
f
@thdxr can u take a look at this when u get a chance?
h