michaelwittig / node-q

Q interfacing with Node.js
MIT License
52 stars 14 forks source link

backtick escape issue for symbol #51

Open cheduo opened 3 years ago

cheduo commented 3 years ago

Hi Michael,

I notice a small issue in sending Q symbol with backtick; Actually we need an extra space to escape the leading backtick. I just tested following code :

var nodeq = require("node-q");
nodeq.connect({host: "localhost", port: 5000}, function(err, con) {
    if (err) throw err;
    con.k("`a`b`c", function(err, res) {
        if (err) throw err;
        console.log("result", res); // Error a`b`c
    });    
    con.k(" `a`b`c", function(err, res) {
        if (err) throw err;
        console.log("result", res); // "result" [ 'a', 'b', 'c' ]
    });
});

We can hack it on user side by adding extra space to query string, but is it possible to fix it at package level ?

Thanks, Duo

michaelwittig commented 3 years ago

Looks like KX Systems stops distributing a version of q that runs on macOS Catalina. Therefore, I can not reproduce your issue.

But by looking at the code, I can see that your case is not handled. You might want to try something like this:

con.k(["`a", "`b", "`c"], function(err, res) {
cheduo commented 3 years ago
    con.k(["`a", "`b", "`c"], function(err, res) {
        if (err) throw err;
        console.log("result", res); // Error: s
    });

the issue is always about heading backtick,

    con.k(" `a", function(err, res) {
        if (err) throw err;
        console.log("result", res); // "result" a
    });
    con.k("`a", function(err, res) {
        if (err) throw err;
        console.log("result", res); // Error: type
    });
michaelwittig commented 3 years ago

You might want to try explicit types:

const nodeq = require("node-q");
[...]
con.k(nodeq. symbols(["a", "b", "c"]), function(err, res) {
    if (err) throw err;
    console.log("result", res); // 5
});

Sorry for not being more helpful here. Without q it's hard to test...