Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 错误:传递字符串时整数的输入语法无效_Node.js_Postgresql_Postgresql 9.1_Postgresql 9.3_Postgresql 9.2 - Fatal编程技术网

Node.js 错误:传递字符串时整数的输入语法无效

Node.js 错误:传递字符串时整数的输入语法无效,node.js,postgresql,postgresql-9.1,postgresql-9.3,postgresql-9.2,Node.js,Postgresql,Postgresql 9.1,Postgresql 9.3,Postgresql 9.2,我在node.js中有以下函数,它基于name\u url对postgres进行查询。有时有效,有时无效 我也在使用lib pg promise: exports.getLawyerByUrlName = function (name_url, callback) { console.log(typeof name_url) //NOTICE: output string db.one({ text: "SELECT * FROM " + lawyers

我在node.js中有以下函数,它基于
name\u url
对postgres进行查询。有时有效,有时无效

我也在使用lib pg promise:

exports.getLawyerByUrlName = function (name_url, callback) {
    console.log(typeof name_url) //NOTICE: output string

    db.one({
            text: "SELECT * FROM " + lawyersTable + " WHERE name_url LIKE $1::varchar",
            values: name_url,
            name: "get-lawyer-by-name_url"
        })
        .then(function (lawyer) {
            callback(lawyer);
        })
        .catch(function (err) {
            console.log("getLawyerByUrlName() " + err)
        });
}
当它不工作时,会抛出错误:

getLawyerByUrlName() error: invalid input syntax for integer: "roberto-guzman-barquero"
这是一个非常奇怪的错误,我似乎无法理解它为什么会发生。我在console.log中检查是否实际传递了字符串:

console.log(typeof name\u url)//注意:输出字符串

名称\ url的“我的表格”字段为:

CREATE TABLE lawyers(
...
  name_url VARCHAR check(translate(name_url, 'abcdefghijklmnopqrstuvwxyz-', '') = '') NOT NULL UNIQUE,

似乎那个特定的查询不太可能抛出那个错误,所以我将提出三种可能性。首先,导致错误的代码实际上是其他地方的代码,并且:

.catch(function (err) {
            console.log("getLawyerByUrlName() " + err)
被剪切并粘贴到代码的不同部分

第二种可能是“lawersTable”变量中填充了意外的内容


第三种可能性是,我的前两种情况是错误的

这个特定的查询似乎不太可能抛出这个错误,所以我建议三种可能性。首先,导致错误的代码实际上是其他地方的代码,并且:

.catch(function (err) {
            console.log("getLawyerByUrlName() " + err)
被剪切并粘贴到代码的不同部分

第二种可能是“lawersTable”变量中填充了意外的内容

第三种可能性是,我的前两种情况是错误的