This repository was archived by the owner on Jun 19, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
packages/dynamodb-expressions/src Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change 1
1
import { AttributeBearingExpression } from "./AttributeBearingExpression" ;
2
2
import { AttributePath } from "./AttributePath" ;
3
3
import { ExpressionAttributes } from "./ExpressionAttributes" ;
4
+ import { FunctionExpression } from "./FunctionExpression" ;
4
5
5
- export type MathematicalExpressionOperand = AttributePath | string | number ;
6
+ export type MathematicalExpressionOperand = AttributePath | FunctionExpression | string | number ;
6
7
7
8
const MATHEMATICAL_EXPRESSION_TAG = 'AmazonDynamoDbMathematicalExpression' ;
8
9
const EXPECTED_TOSTRING = `[object ${ MATHEMATICAL_EXPRESSION_TAG } ]` ;
@@ -21,9 +22,14 @@ export class MathematicalExpression implements AttributeBearingExpression {
21
22
22
23
serialize ( attributes : ExpressionAttributes ) {
23
24
const safeArgs = [ this . lhs , this . rhs ] . map (
24
- arg => AttributePath . isAttributePath ( arg ) || typeof arg === 'string'
25
- ? attributes . addName ( arg )
26
- : attributes . addValue ( arg )
25
+ arg => {
26
+ if ( FunctionExpression . isFunctionExpression ( arg ) ) {
27
+ return arg . serialize ( attributes ) ;
28
+ }
29
+ return AttributePath . isAttributePath ( arg ) || typeof arg === 'string'
30
+ ? attributes . addName ( arg )
31
+ : attributes . addValue ( arg ) ;
32
+ }
27
33
) ;
28
34
return `${ safeArgs [ 0 ] } ${ this . operator } ${ safeArgs [ 1 ] } ` ;
29
35
}
You can’t perform that action at this time.
0 commit comments