Skip to content
This repository was archived by the owner on Feb 7, 2026. It is now read-only.

fix: promise never returned on table.insert - #953

Merged
feywind merged 3 commits into
googleapis:masterfrom
larssn:master
May 5, 2021
Merged

feywind merged 3 commits into
googleapis:masterfrom
larssn:master

Conversation

@larssn

@larssn larssn commented May 1, 2021 •

Copy link
Copy Markdown
Contributor
  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #948

So the table.insert function never returned its promise. This PR fixes that.
It also gets rid of an unnecessary cast.

Two new tests were written:

  • it should return a promise if no callback is provided
  • it should resolve to an array on success

Code coverage goes down to 99.92, due to line 1916 being uncovered (even though thats what the new tests were for).

@larssn
larssn requested review from a team and shollyman May 1, 2021 11:02
@product-auto-label product-auto-label Bot added the api: bigquery Issues related to the googleapis/nodejs-bigquery API. label May 1, 2021
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label May 1, 2021
@feywind feywind self-assigned this May 5, 2021
@codecov

codecov Bot commented May 5, 2021 •

Copy link
Copy Markdown

Codecov Report

Merging #953 (ca609f5) into master (28cf08d) will decrease coverage by 0.02%.
The diff coverage is 80.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #953      +/-   ##
==========================================
- Coverage   98.68%   98.66%   -0.03%     
==========================================
  Files           9        9              
  Lines        7173     7176       +3     
  Branches      442      487      +45     
==========================================
+ Hits         7079     7080       +1     
- Misses         94       96       +2     
Impacted Files Coverage Δ
src/table.ts 99.91% <80.00%> (-0.09%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 28cf08d...ca609f5. Read the comment docs.

@feywind feywind added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 5, 2021
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 5, 2021

@feywind feywind left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree with codecov, I think those lines are covered.

Comment thread src/table.ts
err => callback(err, null)
);
} else {
return promise.then(r => [r]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's sort of odd to me that the Promise returns an array, but the callback isn't called with one. This seems to maintain the method definition though.

@larssn larssn May 6, 2021 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or it could be typescript having trouble determining the return type.
I'm not sure if there's a test for the callback version's return type (there probably should be).

@feywind
feywind merged commit a138347 into googleapis:master May 5, 2021
Comment thread src/table.ts
err => callback(err, null)
);
const promise = this._insertAndCreateTable(rows, options);
if (callback) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is needed, as there's already a promisified version being returned. See

promisifyAll(Table);
.

I think the unhandled rejection may come from further down.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, this PR fixes nothing then. Easy to miss. Not the biggest fan of code like that tbh.

cc @feywind

gcf-merge-on-green Bot pushed a commit that referenced this pull request Jul 21, 2021
🤖 I have created a release \*beep\* \*boop\*
---
## [5.7.0](https://www.github.com/googleapis/nodejs-bigquery/compare/v5.6.0...v5.7.0) (2021-07-21)


### Features

* add `gcf-owl-bot[bot]` to `ignoreAuthors` ([#958](https://www.github.com/googleapis/nodejs-bigquery/issues/958)) ([9eab78d](https://www.github.com/googleapis/nodejs-bigquery/commit/9eab78de56d087f3dc756ab2c0974737a80ad43f))


### Bug Fixes

* **deps:** update dependency yargs to v17 ([#954](https://www.github.com/googleapis/nodejs-bigquery/issues/954)) ([28cf08d](https://www.github.com/googleapis/nodejs-bigquery/commit/28cf08d74184b388cd8d18a9622630939c5f99cf))
* extend definition of Query.types for simple named parameters ([#906](https://www.github.com/googleapis/nodejs-bigquery/issues/906)) ([#907](https://www.github.com/googleapis/nodejs-bigquery/issues/907)) ([44e1ac7](https://www.github.com/googleapis/nodejs-bigquery/commit/44e1ac7cf8604d79508316d70a3a98e2953d59f0))
* handle null query parameter value ([#920](https://www.github.com/googleapis/nodejs-bigquery/issues/920)) ([3bf900a](https://www.github.com/googleapis/nodejs-bigquery/commit/3bf900a54a92c0422fa8f3c48480dc430a7d134d))
* promise never returned on table.insert ([#953](https://www.github.com/googleapis/nodejs-bigquery/issues/953)) ([a138347](https://www.github.com/googleapis/nodejs-bigquery/commit/a138347855f74d4e5c889dc42b00992c4a3808a6))
---


This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: bigquery Issues related to the googleapis/nodejs-bigquery API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

table.insert does not return a Promise

5 participants