Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/66.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
@mysql/xdevapi如何调试“;插入的行中的字段数错误";在nodejs?_Mysql_Node.js_Mysql X Devapi - Fatal编程技术网

@mysql/xdevapi如何调试“;插入的行中的字段数错误";在nodejs?

@mysql/xdevapi如何调试“;插入的行中的字段数错误";在nodejs?,mysql,node.js,mysql-x-devapi,Mysql,Node.js,Mysql X Devapi,我使用新的x-authentication成功连接到本地MySQL服务器。我有一个具有以下模式(DDL)的products表: 我试图在此表中插入以下javascript对象: Product { productID: null, productName: 'product2', descriptionHE: 'תיאור המוצר', descriptionEN: 'product description', displayNameHE: 'מוצר', displa

我使用新的x-authentication成功连接到本地MySQL服务器。我有一个具有以下模式(DDL)的products表:

我试图在此表中插入以下javascript对象:

Product {
  productID: null,
  productName: 'product2',
  descriptionHE: 'תיאור המוצר',
  descriptionEN: 'product description',
  displayNameHE: 'מוצר',
  displayNameEN: 'Product',
  imagePath: 'assets/images/facebook-512.png',
  price: 400
}
我使用以下代码完成此操作:

let table = this.session.getSchema('...').getTable('products')
return table.insert(
  'id', 'name', 'description_he', 'description_en', 'display_name_he', 'display_name_en', 'image_path', 'price', 'is_visible')
    .values(
      5,
      product.name,
      product.descriptionHE,
      product.descriptionEN,
      product.displayNameHE,
      product.displayNameEN,
      product.imagePath,
      product.price,
      1)
    .execute()
    .catch((err) => {
      console.log(err);
    })
这将捕获以下错误:

Error: Wrong number of fields in row being inserted
    at SqlResultHandler.BaseHandler.<computed> (C:\Users\...\node_modules\@mysql\xdevapi\lib\Protocol\InboundHandlers\BaseHandler.js:119:17)
    at Array.entry (C:\Users\...\node_modules\@mysql\xdevapi\lib\Protocol\InboundHandlers\BaseHandler.js:90:29)
    at WorkQueue.process (C:\Users\...\node_modules\@mysql\xdevapi\lib\WorkQueue.js:75:19)
    at Client.handleServerMessage (C:\Users\...\node_modules\@mysql\xdevapi\lib\Protocol\Client.js:208:21)
    at Client.handleNetworkFragment (C:\Users\...\node_modules\@mysql\xdevapi\lib\Protocol\Client.js:252:14)
    at TLSSocket.<anonymous> (C:\Users\...\node_modules\@mysql\xdevapi\lib\Protocol\Client.js:90:36)
    at TLSSocket.emit (events.js:315:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at TLSSocket.Readable.push (internal/streams/readable.js:223:10) {
  info: {
    severity: 0,
    code: 5014,
    sqlState: 'HY000',
    msg: 'Wrong number of fields in row being inserted'
  }
}
错误:插入的行中的字段数错误
在SqlResultHandler.BaseHandler处。(C:\Users\…\node\u modules\@mysql\xdevapi\lib\Protocol\InboundHandlers\BaseHandler.js:119:17)
在Array.entry(C:\Users\…\node\u modules\@mysql\xdevapi\lib\Protocol\InboundHandlers\BaseHandler.js:90:29)
在WorkQueue.process(C:\Users\…\node\u modules\@mysql\xdevapi\lib\WorkQueue.js:75:19)
在Client.handleServerMessage(C:\Users\…\node\u modules\@mysql\xdevapi\lib\Protocol\Client.js:208:21)
位于Client.handleNetworkFragment(C:\Users\…\node\u modules\@mysql\xdevapi\lib\Protocol\Client.js:252:14)
在TLSSocket。(C:\Users\…\node\u modules\@mysql\xdevapi\lib\Protocol\Client.js:90:36)
在TLSSocket.emit(events.js:315:20)
在addChunk(internal/streams/readable.js:309:12)
在readableAddChunk(internal/streams/readable.js:284:9)
在TLSSocket.Readable.push(internal/streams/Readable.js:223:10){
信息:{
严重程度:0,
代码:5014,
sqlState:'HY000',
msg:'插入的行中的字段数错误'
}
}

我试着使用参数并简化了一点表模式,但是我还没有找到错误。您知道如何调试发送到SQL server的查询以找出失败的原因吗?

问题是我使用了product.name而不是product.productName。 结论:使用打字脚本。:)

Error: Wrong number of fields in row being inserted
    at SqlResultHandler.BaseHandler.<computed> (C:\Users\...\node_modules\@mysql\xdevapi\lib\Protocol\InboundHandlers\BaseHandler.js:119:17)
    at Array.entry (C:\Users\...\node_modules\@mysql\xdevapi\lib\Protocol\InboundHandlers\BaseHandler.js:90:29)
    at WorkQueue.process (C:\Users\...\node_modules\@mysql\xdevapi\lib\WorkQueue.js:75:19)
    at Client.handleServerMessage (C:\Users\...\node_modules\@mysql\xdevapi\lib\Protocol\Client.js:208:21)
    at Client.handleNetworkFragment (C:\Users\...\node_modules\@mysql\xdevapi\lib\Protocol\Client.js:252:14)
    at TLSSocket.<anonymous> (C:\Users\...\node_modules\@mysql\xdevapi\lib\Protocol\Client.js:90:36)
    at TLSSocket.emit (events.js:315:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at TLSSocket.Readable.push (internal/streams/readable.js:223:10) {
  info: {
    severity: 0,
    code: 5014,
    sqlState: 'HY000',
    msg: 'Wrong number of fields in row being inserted'
  }
}