diff --git a/src/bigquery.ts b/src/bigquery.ts index 8b22abd2..80e75545 100644 --- a/src/bigquery.ts +++ b/src/bigquery.ts @@ -1113,7 +1113,10 @@ export class BigQuery extends common.Service { // eslint-disable-next-line @typescript-eslint/no-explicit-any private static _getValue(value: any, type: ValueType): any { - if (value.type!) type = value; + if (value === null) { + return null; + } + if (value.type) type = value; return BigQuery._isCustomType(type) ? value.value : value; } diff --git a/test/bigquery.ts b/test/bigquery.ts index 93c4f056..5bfefbc9 100644 --- a/test/bigquery.ts +++ b/test/bigquery.ts @@ -1470,6 +1470,13 @@ describe('BigQuery', () => { geography.value ); }); + + it('should handle null values', () => { + const value = null; + const type = 'TYPE'; + + assert.strictEqual(BigQuery._getValue(value, type), value); + }); }); describe('_isCustomType', () => {