types / mysql2

Typings for https://github.com/sidorares/node-mysql2
ISC License
41 stars 23 forks source link

Confusion over query/execute's return type union via Promise API #24

Open theFroh opened 6 years ago

theFroh commented 6 years ago

Upon console logging an INSERT, I can see the following:

ResultSetHeader {
    fieldCount: 0,
    affectedRows: 1,
    insertId: 0,
    info: '',
    serverStatus: 2,
    warningStatus: 1 }

This would imply that there's a warning. What return packet type would contain this information?

The signature for .query is RowDataPacket[][] | RowDataPacket[] | OkPacket | OkPacket[], and since this is an INSERT I'd expect the result to be an OkPacket if anything, however the OkPacket type definition is:

OkPacket {
    constructor: {
        name: 'OkPacket'
    };
    fieldCount: number;
    affectedRows: number;
    changedRows: number;
    insertId: number;
    serverStatus: number;
    warningCount: number;
    message: string;
    procotol41: boolean;
}

Observations:

So unless I typecast as any I don't believe I can determine if a query has had a warning, but I'd just like to confirm if this is the case and raise this just in case there is indeed an issue in the definition.

dctrotz commented 4 years ago

I am seeing the same thing, yet, this issue seems stalled. :-/