Skip to content

typeCast doesn't seem to work when using a connection pool #894

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

Closed
EnzoMartin opened this issue Aug 24, 2014 · 6 comments
Closed

typeCast doesn't seem to work when using a connection pool #894

EnzoMartin opened this issue Aug 24, 2014 · 6 comments
Labels

Comments

@EnzoMartin
Copy link

I'm using a connection pool, and in the pool config I pass the typeCast option (using the function in the readme as I'm needing to cast tinyint(1) to booleans). I notice that if I output a connection's typeCast function, the setting is correctly configured there, but when I add an output to the first argument it gets back, instead of a field, it gets the table information.

This makes me unable to use typeCast as a global configuration option for all queries, as I need to set it on every query that I want to convert tinyint to booleans

@dougwilson
Copy link
Member

Adding typeCast to the pool definitely works. Can you post the table DDL you are querying, the pool configuration code you are using, and what the "output to the first argument it gets back" is?

@dougwilson
Copy link
Member

Actually, it looks like it may indeed not work.

@dougwilson dougwilson added bug and removed question labels Aug 24, 2014
@dougwilson
Copy link
Member

Specifically, it's only a bug with pool.query; if you acquire a connection from the pool and do conn.query on that, it'll have the pool's type cast setting.

@EnzoMartin
Copy link
Author

Sorry, I should have specified it's when using pool.query. As a side note, doing pool.query and specifying the typeCast then works fine

@EnzoMartin
Copy link
Author

Fastest fix ever, awesome, thank you 👍

@dougwilson
Copy link
Member

Yep. I actually just fixed it :) You can verify it by doing npm install felixge/node-mysql; I should release a patch version today.

seangarner pushed a commit to seangarner/node-mysql that referenced this issue May 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants