Skip to content

Object has no method 'apply' #1060

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
jhiver opened this issue Apr 17, 2015 · 5 comments
Closed

Object has no method 'apply' #1060

jhiver opened this issue Apr 17, 2015 · 5 comments
Assignees
Labels

Comments

@jhiver
Copy link

jhiver commented Apr 17, 2015

Hello, and thanks for your library. Please help me understand this error.... I have this really simple query makes my app crash:

    <snip...>
    # This is the test record that we have imported:
# INSERT INTO portal_users (email, encrypted_password) VALUES ('[email protected]', 'c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2');
mysql.query 'SELECT * FROM portal_users WHERE email=? AND encrypted_password=?', user, hash, (error, results) ->
    if error then return res.sendError 500, error
    return res.sendResult results

Here's the error message:

    TypeError: Object e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 has no method 'apply'
      at Query.Sequence.end (/Users/jhiver/api.life/anemone/server/node_modules/mysql/lib/protocol/sequences/Sequence.js:96:24)
      at Query.ErrorPacket (/Users/jhiver/api.life/anemone/server/node_modules/mysql/lib/protocol/sequences/Query.js:94:8)
      at Protocol._parsePacket (/Users/jhiver/api.life/anemone/server/node_modules/mysql/lib/protocol/Protocol.js:271:23)
      at Parser.write (/Users/jhiver/api.life/anemone/server/node_modules/mysql/lib/protocol/Parser.js:77:12)
      at Protocol.write (/Users/jhiver/api.life/anemone/server/node_modules/mysql/lib/protocol/Protocol.js:39:16)
      at Socket.<anonymous> (/Users/jhiver/api.life/anemone/server/node_modules/mysql/lib/Connection.js:92:28)
      at Socket.emit (events.js:95:17)
      at Socket.<anonymous> (_stream_readable.js:765:14)
      at Socket.emit (events.js:92:17)
      at emitReadable_ (_stream_readable.js:427:10)
      at emitReadable (_stream_readable.js:423:5)
      at readableAddChunk (_stream_readable.js:166:9)
      at Socket.Readable.push (_stream_readable.js:128:10)
      at TCP.onread (net.js:529:21)

And finally the (very simple) table definition:

    CREATE TABLE `portal_users` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `email` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
      `encrypted_password` varchar(128) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
      PRIMARY KEY (`id`),
      UNIQUE KEY `index_users_on_email` (`email`)
    ) ENGINE=MyISAM AUTO_INCREMENT=898 DEFAULT CHARSET=latin1;

Any clues about what's happening here?

Thanks
JM

@AdriVanHoudt
Copy link

try passing the values as an array [user, hash]

@jhiver
Copy link
Author

jhiver commented Apr 17, 2015

slaps head - thank you so much!

@AdriVanHoudt
Copy link

no problem, close the issue if it's fixed

@jhiver jhiver closed this as completed Apr 17, 2015
@dougwilson dougwilson added the bug label Apr 17, 2015
@dougwilson dougwilson self-assigned this Apr 17, 2015
@dougwilson
Copy link
Member

Thanks for helping, @AdriVanHoudt ! I appreciate it :) I'm going to re-open the bug for now so I can remember that I should add more argument validation to the .query() method so the failure is early and easier to understand ;)

@dougwilson dougwilson reopened this Apr 17, 2015
@AdriVanHoudt
Copy link

np and good idea!

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

3 participants