Skip to content

Commit

Permalink
Use run options recursively when converting (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
unleashy authored Aug 1, 2024
1 parent 9211890 commit 70d8e84
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/response/response-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}, {});
}
16 changes: 14 additions & 2 deletions test/accessing-reql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down

0 comments on commit 70d8e84

Please sign in to comment.