Using the following with Hapi 13+
I am able to read from a MySql database but unable to write to it using waterline.
The adaptor logs the following CORRECT SQL that runs fine directly in the DB.
MySQL.create: INSERT INTO donor (username) values ('my-new-donor')
On the very next line it attempts to call a function that's not defined.
`Debug: internal, implementation, error
TypeError: Uncaught error: connection.query is not a function
at __CREATE__ (node_modules/sails-mysql/lib/adapter.js:394:20)
at Object.module.exports.adapter.create (node_modules/sails-mysql/lib/adapter.js:363:9)
at module.exports.create (node_modules/waterline/lib/waterline/adapter/dql.js:86:13)
at createValues (node_modules/waterline/lib/waterline/query/dql/create.js:224:16)
at node_modules/waterline/lib/waterline/query/dql/create.js:74:20
at node_modules/async/lib/async.js:726:13
at node_modules/async/lib/async.js:52:16
at node_modules/async/lib/async.js:269:32
at node_modules/async/lib/async.js:44:16
at node_modules/async/lib/async.js:723:17
at node_modules/async/lib/async.js:167:37
at node_modules/async/lib/async.js:52:16
at node_modules/async/lib/async.js:269:32
at node_modules/async/lib/async.js:44:16
at .<anonymous> (node_modules/waterline/lib/waterline/utils/schema.js:152:44)
at fn (node_modules/waterline/lib/waterline/utils/callbacksRunner.js:41:10)
at node_modules/async/lib/async.js:181:20
at iterate (node_modules/async/lib/async.js:262:13)
at Object.async.forEachOfSeries.async.eachOfSeries (node_modules/async/lib/async.js:281:9)
at Object.async.forEachSeries.async.eachSeries (node_modules/async/lib/async.js:214:22)
at Object.runner.beforeCreate (node_modules/waterline/lib/waterline/utils/callbacksRunner.js:44:9)
at node_modules/waterline/lib/waterline/query/dql/create.js:184:17`
How can we be missing the entire connection.query function?
UPDATE:
Upgrading to sails-mysql 0.12.x seems to have fixed this issues the several times it's reared up.
@failpunk Thanks for posting, we'll take a look as soon as possible. In the meantime, if you haven鈥檛 already, please carefully read the issue contribution guidelines and double-check for any missing information above. In particular, please ensure that this issue is about a stability or performance bug with a documented feature; and make sure you鈥檝e included detailed instructions on how to reproduce the bug from a clean install. Finally, don鈥檛 forget to include the version of Node.js you tested with, as well as your version of Sails or Waterline, and of any relevant standalone adapters/generators/hooks.
Thank you!
So i did some digging, because I had the same problem, and it seems like there is a bug in the adapter.js file anywhere where "connection.query" is called. The way I fixed it is by changing all those lines to: "connectionObject.connection.pool.query". That worked for me, no saying this is the correct solution, but this should be addressed as it is a major show-stopper.
@failpunk Thanks for the report. I saw your Node version, but would you jot down the version of Waterline you're using?
@boxman0617 Are you on Node 6 as well? Also, are you also seeing this with [email protected], or is it on 0.12.x? The tests for the 0.11.x branch are passing, so it seems likely that this could be coming from some kind of conflict- or maybe I'm just missing something. When you have a sec, would you put together the version info from above, as well as the version of Sails you're using? I'll take a closer look and figure out what's going on. Thanks!
@mikermcneil:
Node: 6.2.2
sails-mysql: 0.11.5
No sails version, pure waterline
@mikermcneil
Same problem with
Node: 5.12.0 and 6.2.2
sails-mysql: 0.11.5
No sails either, pure waterline.
@mikermcneil
Same problem with
Node: 4.2.6
sails-mysql: 0.11.5
No Sails, pure waterline.
@mikermcneil
Same problem with
Node : 6.5
waterline : 0.12.2
sails-mysql: 0.11.5
OS : macOS
No sails, pure waterline too.
Upgrading to the latest sails-mysql fixed it for me
npm install --save [email protected]
@failpunk,@sailsbot,@boxman0617,@mikermcneil,@wadeos,@diturriza,@vmarchaud: Hello, I'm a repo bot-- nice to meet you!
It has been 30 days since there have been any updates or new comments on this page. If this issue has been resolved, feel free to disregard the rest of this message and simply close the issue if possible. On the other hand, if you are still waiting on a patch, please post a comment to keep the thread alive (with any new information you can provide).
If no further activity occurs on this thread within the next 3 days, the issue will automatically be closed.
Thanks so much for your help!
Most helpful comment
npm install --save [email protected]