Support Knex#468
Conversation
|
PTAL |
matthewloring
left a comment
There was a problem hiding this comment.
It looks good overall but I agree that we should understand what async work is being done by knex to cause this context loss (even though this bluebird patch does fix this problem).
| databaseResultReportingSize: RESULT_SIZE | ||
| }); | ||
| assert = require('assert'); | ||
| knex = require('./fixtures/knex0.12')({ |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| } | ||
|
|
||
| function patchPromise(Promise, api) { | ||
| shimmer.wrap(Promise.prototype, '_addCallbacks', function(original) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
425818b to
6010c4b
Compare
| shimmer.wrap(Client.prototype, 'runner', function(original) { | ||
| return function() { | ||
| var runner = original.apply(this, arguments); | ||
| runner.query = api.wrap(runner.query); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| function interceptKnex(Knex, api) { | ||
| return function() { | ||
| var result = Knex.apply(this, arguments); | ||
| var proto = Object.getPrototypeOf(result.client); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| var proto = Object.getPrototypeOf(result.client); | ||
| shimmer.wrap(proto, 'transaction', function(original) { | ||
| return function() { | ||
| var args = Array.prototype.slice.call(arguments).map(function(item) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
I think this patch is specific to mysql. I will investigate this further.
This commit intercepts the module root to patch the `transaction` method. This works because the `knex` module exports a constructor and the object that the constructor constructs has a `client` property that is the client being used. This client can have its `transaction` method updated in a way to preserve context.
80d3264 to
aa7279a
Compare
| var util = require('util'); | ||
| var is = require('is'); | ||
|
|
||
| var VERSIONS = '0.12.x'; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
|
||
| function interceptTransaction(Transaction, api) { | ||
| function WrappedTransaction(client, container, config, outerTx) { | ||
| Transaction.call(this, client, wrapIfFn(container, api), config, outerTx); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
matthewloring
left a comment
There was a problem hiding this comment.
LGTM with nit once appveyor and circle are passing (travis failures are unrelated).
| enhancedDatabaseReporting: true, | ||
| databaseResultReportingSize: RESULT_SIZE | ||
| }); | ||
| assert = require('assert'); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This commit includes support and tests for knex satsifying `>=0.10 <=0.13`. PR-URL: googleapis/cloud-trace-nodejs#468
googleapis/synthtool@1df68ed commit 1df68ed6735ddce6797d0f83641a731c3c3f75b4 Author: Alexander Fenster <[email protected]> Date: Mon Apr 6 16:17:34 2020 -0700 fix: apache license URL (#468)
This PR was generated using Autosynth. 🌈 Synth log will be available here: https://source.cloud.google.com/results/invocations/9c94202f-63a5-4df0-9d76-871a00f99b85/targets
This PR was generated using Autosynth. 🌈 Synth log will be available here: https://source.cloud.google.com/results/invocations/9c94202f-63a5-4df0-9d76-871a00f99b85/targets
No description provided.