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/undefined as last query value in mysql and postgres patchers #81

Merged
merged 3 commits into from
Dec 13, 2018

Conversation

M-TGH
Copy link
Contributor

@M-TGH M-TGH commented Dec 12, 2018

Description of changes:

Was beforehand throwing a TypeError when trying to access the constructor property on null or undefined:

connection.query('SELECT a FROM b', null);
// without xray --> resolves query
// with xray    --> throws TypeError: Cannot read property 'constructor' of null  

As far as I know null and undefined are the only data types that will encounter this problem, hence a loose null check should suffice.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Was beforehand throwing a TypeError when trying to access the constructor property on `null` or `undefined`:

```js
connection.query('SELECT a FROM b', null);
// without xray --> resolves query
// with xray    --> throws TypeError: Cannot read property 'constructor' of null  
```

As far as I know null and undefined are the only data types that will encounter this problem, hence a loose null check should suffice.
@M-TGH M-TGH changed the title fix: handle null/undefined as last query value fix: handle null/undefined as last query value in aws-xray-sdk-mysql Dec 12, 2018
@haotianw465
Copy link
Contributor

Thank you for reporting the issue. I believe the postgres package has exactly the same issue. https://github.com/aws/aws-xray-sdk-node/blob/master/packages/postgres/lib/postgres_p.js#L47.

Could you add a test for mysql? If you have extra time would you mind making this change to postgres patcher as well? If not we will merge this and fix postgres using the same code you provide. Please let me know.

@M-TGH
Copy link
Contributor Author

M-TGH commented Dec 12, 2018

Wasn't too sure what way to test it as it's a bit of an edge case, but these test cases will fail without the patch.

Also added the patch to the postgres patcher as it did indeed have the same behaviour.

Let me know if there's anything else.

@M-TGH M-TGH changed the title fix: handle null/undefined as last query value in aws-xray-sdk-mysql fix: handle null/undefined as last query value in mysql and postgres patchers Dec 12, 2018
@haotianw465
Copy link
Contributor

Thank you that should be enough. We will prepare a release soon. We really appreciate your contribution.

@haotianw465 haotianw465 merged commit fb0e4e5 into aws:master Dec 13, 2018
@M-TGH M-TGH deleted the patch-2 branch January 24, 2019 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants