[CONJS-194] Charset change using parameterized query fails with "Uncaught TypeError: opts.emit is not a function" Created: 2022-04-26  Updated: 2022-07-19  Resolved: 2022-04-26

Status: Closed
Project: MariaDB Connector/node.js
Component/s: other
Affects Version/s: 3.0.0
Fix Version/s: 3.0.1

Type: Bug Priority: Major
Reporter: Diego Dupin Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None


 Description   

see https://github.com/mariadb-corporation/mariadb-connector-nodejs/issues/199

(async () => {
    const { strictEqual } = require("assert");
    const Maria = require("mariadb");
    const pool = Maria.createPool({
    	user: "user",
    	password: "password",
    	host: "host"
    });
    
    const query = "SET NAMES 'utf8'";
    
    // Using string directly works as expected
    const result1 = await pool.query(query); 
    strictEqual(result1.constructor.name, "OkPacket");
    console.log("result 1 ok");
 
    // Using { sql: string } fails
    const result2 = await pool.query({ sql: query }); 
    strictEqual(result2.constructor.name, "OkPacket");
    console.log("result 2 ok");
})();

At the same time, with MariaDB server 10.6, changing to utf8 might result in "Error: unknown charset : 'utf8mb3'"


Generated at Thu Feb 08 03:23:27 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.