Closed zfanta closed 7 years ago
can you try non-promise version first and see if you get error?
also, can you show code at project\api\user.js:131
?
@sidorares project\api\user.js:131
is just the end of the function.
I tried non-promise version and it works well. but I'm using koa.js so I prefer to use promise version.
debug log(non-promise)
Add command: Connection
Add command: query
raw: 0a352e362e3336001c0300003c7d24362248237500fff72102007f8015000000000000000000004537244b2f4a643a33323f29006d7973716c5f6e61746976655f70617373776f726400
1 undefined ==> Connection#handshakeInit(0,,78)
Server hello packet: capability flags:2155870207=(long password, found rows, long flag, connect with db, no schema, compress, odbc, local files, ignore space, protocol 41, interactive, ignore sigpipe, transactions, reserved, secure connection, multi statements, multi results, ps multi results, plugin auth, connect attrs, plugin auth lenenc client data, can handle expired passwords, remember options)
Sending handshake packet: flags:8582095=(long password, found rows, long flag, connect with db, odbc, local files, ignore space, protocol 41, ignore sigpipe, transactions, reserved, secure connection, multi results, session track)
1 796 <== Connection#handshakeInit(1,,75)
1 796 <== 47000001cff3820000000000e00000000000000000000000000000000000000000000000726f6f74001476f6cd7d0dfb10f8997a5fce3dd48f293a206b247563616e2d6170692d6e657700
raw: 00000002000000
1 796 ==> Connection#handshakeResult(2,maybeOK,11)
Sending query command: INSERT INTO `user` (`email`, `password`, `name`, `comment`) VALUES ('8123j@asd.com', '$2a$10$qQufIliQbKeha2t9YKxd6.7Flv/eVXHBZhFaLKIJ9eynCBWiRiRkq', 'lkasd', 'nkl') ON DUPLICATE KEY UPDATE `password` = '$2a$10$qQufIliQbKeha2t9YKxd6.7Flv/eVXHBZhFaLKIJ9eynCBWiRiRkq', `name` = 'lkasd', `comment` = 'nkl'
1 796 <== query#start(0,,306)
1 796 <== 2e01000003494e5345525420494e544f20607573657260202860656d61696c602c206070617373776f7264602c20606e616d65602c2060636f6d6d656e7460292056414c554553202827383132336a406173642e636f6d272c20272432612431302471517566496c6951624b656861327439594b7864362e37466c762f65565848425a6846614c4b494a3965796e434257695269526b71272c20276c6b617364272c20276e6b6c2729204f4e204455504c4943415445204b455920555044415445206070617373776f726460203d20272432612431302471517566496c6951624b656861327439594b7864362e37466c762f65565848425a6846614c4b494a3965796e434257695269526b71272c20606e616d6560203d20276c6b617364272c2060636f6d6d656e7460203d20276e6b6c27
raw: 00022302000000
1 796 ==> query#resultsetHeader(1,maybeOK,11)
Resultset header received, expecting 0 column definition packets
stderr(non-promise)
Trace
at Connection.handlePacket (project\node_modules\mysql2\lib\connection.js:470:15)
at PacketParser.onPacket (project\node_modules\mysql2\lib\connection.js:94:16)
at PacketParser.executeStart (project\node_modules\mysql2\lib\packet_parser.js:77:14)
at Socket.<anonymous> (project\node_modules\mysql2\lib\connection.js:102:29)
at emitOne (events.js:115:13)
at Socket.emit (events.js:210:7)
at addChunk (_stream_readable.js:252:12)
at readableAddChunk (_stream_readable.js:239:11)
at Socket.Readable.push (_stream_readable.js:197:10)
at TCP.onread (net.js:589:20)
Trace
at Connection.handlePacket (project\node_modules\mysql2\lib\connection.js:470:15)
at PacketParser.onPacket (project\node_modules\mysql2\lib\connection.js:94:16)
at PacketParser.executeStart (project\node_modules\mysql2\lib\packet_parser.js:77:14)
at Socket.<anonymous> (project\node_modules\mysql2\lib\connection.js:102:29)
at emitOne (events.js:115:13)
at Socket.emit (events.js:210:7)
at addChunk (_stream_readable.js:252:12)
at readableAddChunk (_stream_readable.js:239:11)
at Socket.Readable.push (_stream_readable.js:197:10)
at TCP.onread (net.js:589:20)
Trace
at Connection.handlePacket (project\node_modules\mysql2\lib\connection.js:470:15)
at PacketParser.onPacket (project\node_modules\mysql2\lib\connection.js:94:16)
at PacketParser.executeStart (project\node_modules\mysql2\lib\packet_parser.js:77:14)
at Socket.<anonymous> (project\node_modules\mysql2\lib\connection.js:102:29)
at emitOne (events.js:115:13)
at Socket.emit (events.js:210:7)
at addChunk (_stream_readable.js:252:12)
at readableAddChunk (_stream_readable.js:239:11)
at Socket.Readable.push (_stream_readable.js:197:10)
at TCP.onread (net.js:589:20)
could it be that router.post
is undefined for some reason?
@sidorares, it was problem of assignment, not this module.
line 115: ... await connection.query('INSERT ...
returns [Object, undefined]
, so lvalue [[row]]
had to be like [{insertId},]
I wrote query that insert a user or update on duplicate(email)
It works well on other mysql clients, but mysql2 throws error.
code
debug log
stderr