Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle null query parameter value #920

Merged
merged 9 commits into from
Jun 6, 2021
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