From 70d8e84786c3140cc07135c4b5101852ed29a4fb Mon Sep 17 00:00:00 2001 From: unleashy Date: Thu, 1 Aug 2024 07:01:26 -0300 Subject: [PATCH] Use run options recursively when converting (#127) --- src/response/response-parser.ts | 2 +- test/accessing-reql.ts | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/response/response-parser.ts b/src/response/response-parser.ts index 1a97d12..c1db68f 100644 --- a/src/response/response-parser.ts +++ b/src/response/response-parser.ts @@ -67,7 +67,7 @@ export function getNativeTypes( } } return Object.entries(obj).reduce((acc: any, [key, val]) => { - acc[key] = getNativeTypes(val); + acc[key] = getNativeTypes(val, { binaryFormat, groupFormat, timeFormat }); return acc; }, {}); } diff --git a/test/accessing-reql.ts b/test/accessing-reql.ts index 4540faa..2e5b217 100644 --- a/test/accessing-reql.ts +++ b/test/accessing-reql.ts @@ -250,14 +250,26 @@ describe('accessing-reql', () => { const result3 = await r.now().run(connection, { timeFormat: 'raw' }); // @ts-ignore assert.equal(result3.$reql_type$, 'TIME'); + + const result4 = await r + .expr({ date: r.now() }) + .run(connection, { timeFormat: 'raw' }); + // @ts-ignore + assert.equal(result4.date.$reql_type$, 'TIME'); }); it('`binaryFormat` should work', async () => { - const result = await r + const result1 = await r .binary(Buffer.from([1, 2, 3])) .run(connection, { binaryFormat: 'raw' }); // @ts-ignore - assert.equal(result.$reql_type$, 'BINARY'); + assert.equal(result1.$reql_type$, 'BINARY'); + + const result2 = await r + .expr({ binary: r.binary(Buffer.from([3, 2, 1])) }) + .run(connection, { binaryFormat: 'raw' }); + // @ts-ignore + assert.equal(result2.binary.$reql_type$, 'BINARY'); }); it('`groupFormat` should work', async () => {