Closed snarky-puppy closed 2 years ago
Dang, this one might be tricky to workaround because of how typesafe-dynamodb uses recursive types to parse the UpdateExpression. At a certain point, the string length is too long, requiring >50 depth (TS's hard-coded maximum). The only way to solve this that I can think of is to try and optimize the code that parses the string:
Some workaround ideas:
// @ts-ignore
on top and skip the checking - not ideal, at all
// @ts-ignore
UpdateExpression: `SET MyMapName.myLongFieldNameA = :myLongFieldValueA,
MyMapName
and myLongFieldNameA
to shorten the UpdateExpression string. The string length will affect the depth because each character is consumed recursively.
UpdateExpression: `SET #m.#n1 = :v1`
ExpressionAttributeNames: {
"#m": "MyMapName",
"#n1": "myLongFieldNameA"
}
I hope these workarounds can unblock you. I will take a look and see if there are any optimizations I can do.
Had a brainwave and figured out a way to extend the limit by splitting the update expression by ,
and processing each string separately. The 50-max depth limit will now only apply to a single expression. I tested with your example and it now compiles - i even found an error in it ;)
Fixed in 0.1.8
.
Awesome, thanks @sam-goodwin ! Learning a lot from your code :-)
Good morning!
I'm trying to update a large map. In other use cases the validation is working perfectly, but after we add about 10-15 fields, we start getting the error above.
Example code: