fsprojects / FSharp.AWS.DynamoDB

F# wrapper API for AWS DynamoDB
MIT License
58 stars 18 forks source link

using Map.containsKey does not use expression attribute #63

Open f-messner opened 1 year ago

f-messner commented 1 year ago

Hello,

I have DynamoDB entries which hold a F# Map<string,string> called values, with keys following a specific schema (X+GUID, where X is a string with letters and digits AND special characters, namely dots, colons underscores and dashes (. : _ -), and GUID is a regular old guid also containing dashes.

Now when I use this library for a query like: <@ fun p -> Map.containsKey s p.values @> |> template.PrecomputeConditionalExpr

I run into some problems, since the generated expression looks like this: attribute_exists ( #ATTR6.xxx:xxx.xxx:xx.xxx:x.xx_xxxx-xx+xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx-xxxxxxxx) that is, values is replaced with a expression attribute (I think that is the right DynamoDB term? Sorry, somewhat new to AWS), but my Map key is not.

Printing out the .Names of this ConditionExpression as well I can see that ATTR6 is mapped correctly [(#ATTR6, values)]

The issue here is that the expression contains illegal characters (running the query fails at the first : but I guess the dots would also do it) and I assume would need to use a expression attribute as well?

Is this something I can fix with correct usage of the library, a bug/oversight in the library, or something that cannot be supported?

Cheers!

samritchie commented 1 year ago

This is probably a bug - I'll need to dig in to what it should be doing there.