-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't conditionally update custom mapped list of strings with empty value #335
Comments
Seems like this is due to line 310 in function validateForOperator(operator: ConditionOperator, values?: any[]) {
validateArity(operator, values)
/*
* validate values if operator supports values
*/
if (!isFunctionOperator(operator) || (isFunctionOperator(operator) && !isNoParamFunctionOperator(operator))) {
if (values && Array.isArray(values) && values.length) {
validateValues(operator, values)
} else {
throw new Error(
dynamicTemplate(ERR_ARITY_DEFAULT, { parameterArity: operatorParameterArity(operator), operator }),
)
}
}
} Also empty arrays are striped by the export function buildFilterExpression(
attributePath: string,
operator: ConditionOperator,
values: any[],
existingValueNames: string[] | undefined,
metadata: Metadata<any> | undefined,
): Expression {
// metadata get rid of undefined values
values = deepFilter(values, (value) => value !== undefined) This is legal to DynamoDB TransactItems: [
{
Update: {
TableName: ...,
Key: ...,
ConditionExpression: 'myList = :emptyList',
UpdateExpression: 'SET myList = :myList',
ExpressionAttributeValues: {
':emptyList': { L: [] },
':myList': { L: [{ S: 'value' }] },
},
},
}
] |
any progress on this issue? I'm experiencing the same problem which leads to an issue with GraphQL resolvers with nonNull lists |
I ended up just using the using the dynamodb client directly for this specific use case. |
This problem extends to all actions containing empty arrays, not just condition expressions. I can't see any reason |
Related to this: shiftcode#335 Suggested changes: https://github.com/Fantom-App/dynamo-easy/pull/1/files Tested agains db
Any changes the suggested fix will be added into this repo? Would be great 😄 |
Describe the bug
If I have a property with a custom mapper like
and I try to do a conditional transact update like:
I get
Error: expected 1 value(s) for operator =, this is not the right amount of method parameters for this operator
This works fine if the list is populated but fails when the list is empty
Expected behavior
I expect the operation to succeed if the list is empty and fail if the list is not empty. I do not expect an error
The text was updated successfully, but these errors were encountered: