mariadb-corporation / mariadb-connector-nodejs

MariaDB Connector/Node.js is used to connect applications developed on Node.js to MariaDB and MySQL databases. MariaDB Connector/Node.js is LGPL licensed.
GNU Lesser General Public License v2.1
378 stars 96 forks source link

add meta result attribute when calling a stored procedure #296

Open TataFalat opened 1 month ago

TataFalat commented 1 month ago

Dear developers, I am considering moving from mysql to mariadb in my node.js BE implementation. I would really appreciate adding meta result attribute when calling a stored procedure. My BE implementation uses stored procedures to retrieve data and it relies on metadata info. I suppose it is possible to add it the same way you add it to SELECT queries. Thank you in advance, Jan.

rusher commented 1 month ago

stored procedure result have metadata as well.

example for CREATE PROCEDURE stmtSimple (IN p1 INT, IN p2 INT) begin SELECT p1 + p2 t; end

const rows = await shareConn.query('call stmtSimple(?,?)', [2, 2]);
    console.log(rows);
    // logged:
    // [
    //   [ { t: 4n } ],
    //   OkPacket { affectedRows: 0, insertId: 0n, warningStatus: 0 }
    // ]
    console.log(rows[0].meta);
    // logged:
    //   [
    //     ColumnDef {
    //     collation: Collation {
    //     index: 63,
    //     name: 'BINARY',
    //     charset: 'binary',
    //     maxLength: 1
    //   },
    //     columnLength: 12,
    //     columnType: 8,
    //     flags: 128,
    //     scale: 0,
    //     type: 'BIGINT'
    // }
    // ]
    //   [
    //     ColumnDef {
    //     collation: Collation {
    //     index: 63,
    //     name: 'BINARY',
    //     charset: 'binary',
    //     maxLength: 1
    //   },
    //     columnLength: 12,
    //     columnType: 8,
    //     flags: 128,
    //     scale: 0,
    //     type: 'BIGINT'
    // }

Could you tell what you expect ?

rusher commented 1 month ago

ah, maybe this is because the difference compared to a SELECT command is that stored procedure will return 2 results. (there is always an additional OkPacket when executing a stored procedure). If you want to compare to a SELECT, you'll have to use only the first result.

TataFalat commented 1 month ago

Thank you for your help. Kind regards, Jan.

On Monday, October 14, 2024 at 03:52:45 PM GMT+2, diego dupin ***@***.***> wrote:  

ah, maybe this is because the difference compared to a SELECT command is that stored procedure will return 2 results. (there is always an additional OkPacket when executing a stored procedure). If you want to compare to a SELECT, you'll have to use only the first result.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>