Skip to content

Commit a99b18f

Browse files
Merge pull request #632 from aerospike/exp-map-fix
Smalls fixes around getListType and getMapType
2 parents bcc1273 + 29a98b2 commit a99b18f

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

lib/exp_lists.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ const _rtype = _valueExp(exp.ops.VAL_RTYPE, 'intVal')
2626
*********************************************************************************/
2727

2828
function getListType (type, returnType, isMulti) {
29+
if (!Object.values(exp.type).includes(type)) {
30+
throw new TypeError('invalid value for valueType parameter')
31+
}
32+
2933
let expected = type
3034

3135
switch (returnType & ~lists.returnType.INVERTED) {
@@ -43,9 +47,12 @@ function getListType (type, returnType, isMulti) {
4347
expected = exp.type.LIST
4448
}
4549
break
50+
case lists.returnType.EXISTS:
51+
expected = exp.type.BOOL
52+
break
4653
case lists.returnType.NONE:
4754
default:
48-
throw new TypeError('either set the value type as auto or match with return object data type')
55+
throw new TypeError('either set the return type as auto or match with return object data type')
4956
}
5057

5158
if (type === exp.type.AUTO || type === expected) {

lib/exp_maps.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ const _rtype = _valueExp(exp.ops.VAL_RTYPE, 'intVal')
1111
*********************************************************************************/
1212

1313
function getMapType (type, returnType, isMulti) {
14+
if (!Object.values(exp.type).includes(type)) {
15+
throw new TypeError('invalid value for valueType parameter')
16+
}
17+
1418
let expected = type
1519

1620
switch (returnType & ~maps.returnType.INVERTED) {
@@ -29,12 +33,17 @@ function getMapType (type, returnType, isMulti) {
2933
expected = exp.type.LIST
3034
}
3135
break
36+
case maps.returnType.EXISTS:
37+
expected = exp.type.BOOL
38+
break
3239
case maps.returnType.KEY_VALUE:
40+
case maps.returnType.ORDERED_MAP:
41+
case maps.returnType.UNORDERED_MAP:
3342
expected = exp.type.MAP
3443
break
3544
case maps.returnType.NONE:
3645
default:
37-
throw new TypeError('either set the value type as auto or match with return object data type')
46+
throw new TypeError('either set the return type as auto or match with return object data type')
3847
}
3948

4049
if (type === exp.type.AUTO || type === expected) {

0 commit comments

Comments
 (0)