From 3bf900a54a92c0422fa8f3c48480dc430a7d134d Mon Sep 17 00:00:00 2001 From: Steffany Brown <30247553+steffnay@users.noreply.github.com> Date: Sun, 6 Jun 2021 10:52:15 -0700 Subject: [PATCH] fix: handle null query parameter value (#920) * fix: update to handle null query param * refactor * update * update null check * removes _isCustomType stub from null parameter values test --- src/bigquery.ts | 5 ++++- test/bigquery.ts | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) 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', () => {