Skip to content
This repository was archived by the owner on Feb 7, 2026. It is now read-only.

Commit 1b7a52e

Browse files
authored
fix: encode values with null prototype (#1219)
1 parent 7f41334 commit 1b7a52e

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/table.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ class Table extends ServiceObject {
570570
'BigQueryTimestamp',
571571
'Geography',
572572
];
573-
const constructorName = value.constructor.name;
573+
const constructorName = value.constructor?.name;
574574
const isCustomType =
575575
customTypeConstructorNames.indexOf(constructorName) > -1;
576576

test/table.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,14 @@ describe('BigQuery/Table', () => {
434434
'-99999999999999999999999999999.999999999'
435435
);
436436
});
437+
438+
it('should return properly encode objects with null prototype', () => {
439+
const obj = Object.create(null);
440+
obj['name'] = 'Test';
441+
assert.deepStrictEqual(Table.encodeValue_(obj), {
442+
name: 'Test',
443+
});
444+
});
437445
});
438446

439447
describe('formatMetadata_', () => {

0 commit comments

Comments
 (0)