Skip to content

Commit

Permalink
fix: handle null query parameter value (#920)
Browse files Browse the repository at this point in the history
* fix: update to handle null query param

* refactor

* update

* update null check

* removes _isCustomType stub from null parameter  values test
  • Loading branch information
steffnay authored Jun 6, 2021
1 parent b703db8 commit 3bf900a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/bigquery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
7 changes: 7 additions & 0 deletions test/bigquery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 3bf900a

Please sign in to comment.