You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the SET NAMES statement inside of a pool.query({ sql: query }) call, the execution fails with TypeError opts.emit is not a function.
Consider the following script:
(async()=>{const{ strictEqual }=require("assert");constMaria=require("mariadb");constpool=Maria.createPool({user: "user",password: "password",host: "host"});constquery="SET NAMES 'utf8'";// Using string directly works as expectedconstresult1=awaitpool.query(query);strictEqual(result1.constructor.name,"OkPacket");console.log("result 1 ok");// Using { sql: string } failsconstresult2=awaitpool.query({sql: query});strictEqual(result2.constructor.name,"OkPacket");console.log("result 2 ok");})();
In mariadb version 2.5.2, the snippet passes, whereas in 3.0.0, the following error is thrown when attempting to initialize result2:
Uncaught TypeError: opts.emit is not a function
at Query.parseOkPacket (VM195 command.js:142:24)
at Query.readOKPacket (VM214 parser.js:108:27)
at Query.readResponsePacket (VM214 parser.js:46:21)
at PacketInputStream.receivePacketBasic (VM164 packet-input-stream.js:76:9)
at PacketInputStream.onData (VM164 packet-input-stream.js:139:20)
at Socket.emit (node:events:527:28)
at addChunk (node:internal/streams/readable:324:12)
at readableAddChunk (node:internal/streams/readable:297:9)
at Readable.push (node:internal/streams/readable:234:10)
at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
Using other meta SQL commands (such as USE database) seems to cause no issues. Other arguments for SET NAMES fail similarly to utf8mb4.
Tested on NodeJS versions 12.22.9, 14.15.0, 16.14.2, 18.0.0, with identical results.
The text was updated successfully, but these errors were encountered:
When using the
SET NAMESstatement inside of apool.query({ sql: query })call, the execution fails with TypeErroropts.emit is not a function.Consider the following script:
In
mariadbversion2.5.2, the snippet passes, whereas in3.0.0, the following error is thrown when attempting to initializeresult2:Using other meta SQL commands (such as
USE database) seems to cause no issues. Other arguments forSET NAMESfail similarly toutf8mb4.Tested on NodeJS versions
12.22.9,14.15.0,16.14.2,18.0.0, with identical results.The text was updated successfully, but these errors were encountered: