Bug #84584 Unable to bind parameters
Submitted: 20 Jan 13:14 Modified: 23 Jan 12:43
Reporter: William Chiquito Email Updates:
Status: Verified Impact on me:
None 
Category:Connector for Node.js Severity:S2 (Serious)
Version:1.0.5 m4 OS:Any
Assigned to:
Tags: BIND, NodeJS, XDevAPI

[20 Jan 13:14] William Chiquito
Description:
When trying to bind parameters using Connector/Node.js, the parameters are not bound.

Error:

TypeError: Cannot read property 'country' of undefined
    at data.args.criteria.placeholders.named.map.key (/user/workspace/js-test/node_modules/@mysql/xdevapi/lib/Protocol/Client.js:357:88)
    at Array.map (native)
    at Client.crudFind (/user/workspace/js-test/node_modules/@mysql/xdevapi/lib/Protocol/Client.js:357:49)
    at CollectionFind.execute (/user/workspace/js-test/node_modules/@mysql/xdevapi/lib/DevAPI/CollectionFind.js:104:10)
    at xdevapi.getSession.then.then.then.collection (/user/workspace/js-test/test.js:23:23)
    at process._tickCallback (internal/process/next_tick.js:103:7)

How to repeat:
/*
Using:
    * Node.js: v7.4.0
    * MySQL: 5.7.17
    * Schema: world_x http://downloads.mysql.com/docs/world_x-db.zip
    * Connector/Node.js: 1.0.5 m4 https://dev.mysql.com/get/Downloads/Connector-Nodejs/mysql-connector-nodejs-1.0.5.tar.gz
*/

const xdevapi = require('@mysql/xdevapi');

xdevapi.getSession({
    host: 'localhost',
    port: '33060',
    dbUser: process.env.user,
    dbPassword: process.env.password
}).then(session => {
    return session.getSchema('world_x');
}).then(schema => {
    return schema.getCollection('countryinfo');
}).then(collection => {
    /* Work
    return collection.find('$.Name == "Mexico"')
                     .execute(docs => {
                         console.log(docs);
                         process.exit();
                     });
    */
    // Not work
    return collection.find('$.Name == :country')
                     .bind({ country: 'Mexico' })
                     .execute(docs => {
                         console.log(docs);
                         process.exit();
                     });
}).catch(err => {
    console.log(err);
    process.exit();
});
[23 Jan 12:43] Chiranjeevi Battula
Hello William Chiquito,

Thank you for the bug report.

Thanks,
Chiranjeevi.