diff --git a/src/table.ts b/src/table.ts index f264f5e0..86c21747 100644 --- a/src/table.ts +++ b/src/table.ts @@ -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; diff --git a/test/table.ts b/test/table.ts index b224bb08..3edc92e1 100644 --- a/test/table.ts +++ b/test/table.ts @@ -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_', () => {