在查询MySQL数据库时,解析器将函数抛出错误?

时间:2016-12-04 09:11:53

标签: mysql node.js

我一直在编写一个程序,并且遇到了Google没有带来任何结果的错误。我正在使用async.series顺序执行多个查询。但是,我的第一个查询返回一个非常奇怪的错误,谷歌没有返回任何结果。任何帮助表示赞赏!

错误:

    C:\path_to_root_project_folder\node_modules\mysql\lib\protocol\Parser.js:78
        throw err; // Rethrow non-MySQL errors
        ^
 function () {
    var args = arguments,
        index = -1,
        length = nativeMax(args.length - start, 0),
        array = Array(length);

    while (++index < length) {
      array[index] = args[start + index];
    }
    index = -1;
    var otherArgs = Array(start + 1);
    while (++index < start) {
      otherArgs[index] = args[index];
    }
    otherArgs[start] = transform(array);
    return apply(func, this, otherArgs);
  }

代码:

async.series([
        function(callback){ //generate uuid
            console.log("generating uuid..");
            newUuid = uuid(); //these are also defined
            console.log("$$$$$$$$$$$$ " + email); //email is defined in the function this async series is nested in
            callback(null);
            return;
        },
        function(callback){
            console.log("$$$$$$$ querying email");
            pool.query("SELECT * FROM users WHERE INSTR(email, '" + email + "') > 0", function(err, rows){  //I think it errors out here?
                if(err) {
                    throw err;
                }
                if(rows[0] != null){
                    res.json({ //res is defined
                    status: 200,
                    success: "EmailExists"
                });
                res.end();
                duplicate = true; //duplicate is defined
                callback(err);
                }
                callback(err);
            });

        }], function(error){if(error) throw err;});

编辑:在使用断点进一步调查后,我发现错误在另一个SQL查询中进一步下降。出于某种原因,抛出的错误是“[object Object]。

代码:(这是我原始代码中的最后一个异步系列之后

function(callback){

        pool.query("SELECT * FROM chapters WHERE INSTR(school, '" + school + "') > 0", function(err, rows){
            if(err) throw err;
            debugger;
            callback(rows);
        });  
    },

0 个答案:

没有答案