Skip to content

Commit

Permalink
fix: encode values with null prototype (#1219)
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarowolfx authored Jul 10, 2023
1 parent 7f41334 commit 1b7a52e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ class Table extends ServiceObject {
'BigQueryTimestamp',
'Geography',
];
const constructorName = value.constructor.name;
const constructorName = value.constructor?.name;
const isCustomType =
customTypeConstructorNames.indexOf(constructorName) > -1;

Expand Down
8 changes: 8 additions & 0 deletions test/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,14 @@ describe('BigQuery/Table', () => {
'-99999999999999999999999999999.999999999'
);
});

it('should return properly encode objects with null prototype', () => {
const obj = Object.create(null);
obj['name'] = 'Test';
assert.deepStrictEqual(Table.encodeValue_(obj), {
name: 'Test',
});
});
});

describe('formatMetadata_', () => {
Expand Down

0 comments on commit 1b7a52e

Please sign in to comment.