You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The DynamoDB documentation for the size() function in ConditionException claims that it requires a path parameter - size(x) and size(#xyz) work. If the data read from that path has a type that size() can't work on (e.g., an integer), the condition fails with ConditionalCheckFailedException. So far so good, and Alternator behaves like DynamoDB in all these cases.
But it turns out that DynamoDB also allows size's parameter to be a value instead of a path - i.e., size(:xyz) works even thought it's not documented. If the value :xyz defined in ExpressionAttributeValues has a suitable type (e.g., a string) its size is defined and the condition using the size may pass. But if the value of :xyz has the wrong type (e.g., an integer), DynamoDB knows the error is in the query itself - not the data - and generates a ValidationException, with the error message: Invalid ConditionExpression: Incorrect operand type for operator or function; operator or function: size, operand type: N.
Trying to use size(size(x)) also generates the same ValidationException - it's also a wrong type (size(x) is an integer, and size() can't be called on that) and known from the query - not from the data.
The importance of this issue is very minor - it's only about the appropriate error type in a case that is in any case erroneous. Alternator also allows size(:xyz) in cases where it's properly defined.
The text was updated successfully, but these errors were encountered:
The DynamoDB documentation for the size() function claims that it only
works on paths (attribute names or references), but it actually works on
constants from the query (e.g., ":val") as well.
It turns out that Alternator supports this undocumented case already, but
gets the error path wrong: Usually, when size() is calculated on the data,
if the data has the wrong type of size() (e.g., an integer), the condition
simply doesn't match. But if the value comes from the query - it should
generate an error that the query is wrong - ValidationException.
This patch fixes this case, and also adds tests for it that pass on both
DynamoDB and Alternator (after this patch).
Fixesscylladb#14592
Signed-off-by: Nadav Har'El <nyh@scylladb.com>
The DynamoDB documentation for the size() function claims that it only
works on paths (attribute names or references), but it actually works on
constants from the query (e.g., ":val") as well.
It turns out that Alternator supports this undocumented case already, but
gets the error path wrong: Usually, when size() is calculated on the data,
if the data has the wrong type of size() (e.g., an integer), the condition
simply doesn't match. But if the value comes from the query - it should
generate an error that the query is wrong - ValidationException.
This patch fixes this case, and also adds tests for it that pass on both
DynamoDB and Alternator (after this patch).
Fixesscylladb#14592
Signed-off-by: Nadav Har'El <nyh@scylladb.com>
Closesscylladb#14593
The DynamoDB documentation for the size() function in ConditionException claims that it requires a path parameter -
size(x)
andsize(#xyz)
work. If the data read from that path has a type that size() can't work on (e.g., an integer), the condition fails withConditionalCheckFailedException
. So far so good, and Alternator behaves like DynamoDB in all these cases.But it turns out that DynamoDB also allows size's parameter to be a value instead of a path - i.e.,
size(:xyz)
works even thought it's not documented. If the value:xyz
defined inExpressionAttributeValues
has a suitable type (e.g., a string) its size is defined and the condition using the size may pass. But if the value of:xyz
has the wrong type (e.g., an integer), DynamoDB knows the error is in the query itself - not the data - and generates aValidationException
, with the error message:Invalid ConditionExpression: Incorrect operand type for operator or function; operator or function: size, operand type: N
.Trying to use
size(size(x))
also generates the sameValidationException
- it's also a wrong type (size(x) is an integer, and size() can't be called on that) and known from the query - not from the data.The importance of this issue is very minor - it's only about the appropriate error type in a case that is in any case erroneous. Alternator also allows
size(:xyz)
in cases where it's properly defined.The text was updated successfully, but these errors were encountered: