Skip to content

Commit 3f72cc6

Browse files
committed
fix vsetattr return type
1 parent 5a49190 commit 3f72cc6

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

packages/client/lib/commands/VSETATTR.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,23 @@ describe('VSETATTR', () => {
3131
client: GLOBAL.SERVERS.OPEN,
3232
cluster: GLOBAL.CLUSTERS.OPEN
3333
});
34+
35+
testUtils.testWithClient('vSetAttr with RESP3 - returns boolean', async client => {
36+
await client.vAdd('resp3-key', [1.0, 2.0, 3.0], 'resp3-element');
37+
38+
const result = await client.vSetAttr('resp3-key', 'resp3-element', {
39+
name: 'test-item',
40+
category: 'electronics',
41+
price: 99.99
42+
});
43+
44+
// RESP3 returns boolean instead of number
45+
assert.equal(typeof result, 'boolean');
46+
assert.equal(result, true);
47+
}, {
48+
...GLOBAL.SERVERS.OPEN,
49+
clientOptions: {
50+
RESP: 3
51+
}
52+
});
3453
});

packages/client/lib/commands/VSETATTR.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { CommandParser } from '../client/parser';
2-
import { RedisArgument, NumberReply, Command } from '../RESP/types';
2+
import { RedisArgument, NumberReply, Command, BooleanReply } from '../RESP/types';
33

44
export default {
55
/**
@@ -27,5 +27,8 @@ export default {
2727
parser.push(attributes);
2828
}
2929
},
30-
transformReply: undefined as unknown as () => NumberReply
30+
transformReply: {
31+
2: undefined as unknown as () => NumberReply,
32+
3: undefined as unknown as () => BooleanReply
33+
}
3134
} as const satisfies Command;

0 commit comments

Comments
 (0)