bigquery: table.insert: correct docs#2153
Conversation
|
I would love to see a test that verifies that this example actually works in v0.49.0 or is it only for v0.50.0? I know that the code I wrote two weeks ago was working fine in the |
|
I just tried causing a failure using promises, both on master and from the git tag when we released 0.49.0, and the success handler did not trigger, while the catch was executed with the expected PartialFailureError. The reason why we're not adding a unique promise test is because this method is no exception from how all of our others behave, in terms of how callbacks/promises are handled. By checking that the callback style works, we are simultaneously confirming it works with promises, as we know the promise behavior is consistent across our API. I'm not sure how to explain this scenario you mentioned in #2149: this.table.insert(item, { raw: false }).then((data) => {
let insertErrors = data[1];
// --------------------
// data[1] should be undefined, we only executed this with one argument, the apiResponse
// --------------------
if (insertErrors) {
logger.info(`insertErrors: ${JSON.stringify(insertErrors)}`);
// Some rows failed to insert, while others may have succeeded.
insertErrors.map((insertError) => {
insertError.errors.map((error) => {
logger.error(`PartialFailureError: BigQuery insert failed due to: ${JSON.stringify(error)}`);
});
});
}
return message;
}).catch((error) => {
throw new Error(`Error inserting into bigQuery for id: "${item.id}": ${JSON.stringify(error)}`);
});Could you provide an isolated, reproducible example in that issue if you're still seeing an apiResponse in the success handler that has insertErrors? |
|
OK, that makes a lot of sense. Thank you. I will run some more tests on my end. |
Fixes #2149