Skip to content

Commit 2c62753

Browse files
authored
chore: add string type to Table.query & Dataset.query (#1000)
1 parent 6c3b0d9 commit 2c62753

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

handwritten/bigquery/src/dataset.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,9 @@ class Dataset extends ServiceObject {
11391139
}
11401140

11411141
query(options: Query): Promise<QueryRowsResponse>;
1142+
query(options: string): Promise<QueryRowsResponse>;
11421143
query(options: Query, callback: SimpleQueryRowsCallback): void;
1144+
query(options: string, callback: SimpleQueryRowsCallback): void;
11431145
/**
11441146
* Run a query scoped to your dataset.
11451147
*
@@ -1151,7 +1153,7 @@ class Dataset extends ServiceObject {
11511153
* @returns {Promise<QueryRowsResponse>} See {@link BigQuery#query} for full documentation of this method.
11521154
*/
11531155
query(
1154-
options: Query,
1156+
options: Query | string,
11551157
callback?: SimpleQueryRowsCallback
11561158
): void | Promise<QueryRowsResponse> {
11571159
if (typeof options === 'string') {

handwritten/bigquery/src/table.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2271,6 +2271,7 @@ class Table extends common.ServiceObject {
22712271
}
22722272

22732273
query(query: Query): Promise<SimpleQueryRowsResponse>;
2274+
query(query: string): Promise<SimpleQueryRowsResponse>;
22742275
query(query: Query, callback: SimpleQueryRowsCallback): void;
22752276
/**
22762277
* Run a query scoped to your dataset.
@@ -2281,9 +2282,14 @@ class Table extends common.ServiceObject {
22812282
* @returns {Promise<SimpleQueryRowsResponse>}
22822283
*/
22832284
query(
2284-
query: Query,
2285+
query: Query | string,
22852286
callback?: SimpleQueryRowsCallback
22862287
): void | Promise<SimpleQueryRowsResponse> {
2288+
if (typeof query === 'string') {
2289+
query = {
2290+
query,
2291+
};
2292+
}
22872293
this.dataset.query(query, callback!);
22882294
}
22892295

handwritten/bigquery/test/table.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2784,7 +2784,7 @@ describe('BigQuery/Table', () => {
27842784
describe('query', () => {
27852785
it('should pass args through to datasetInstance.query()', done => {
27862786
table.dataset.query = (a: {}, b: {}) => {
2787-
assert.strictEqual(a, 'a');
2787+
assert.deepStrictEqual(a, {query: 'a'});
27882788
assert.strictEqual(b, 'b');
27892789
done();
27902790
};

0 commit comments

Comments
 (0)