Skip to content

Commit

Permalink
Merge pull request #111 from jdeniau/raw-sql-without-data
Browse files Browse the repository at this point in the history
  • Loading branch information
jdeniau authored Oct 7, 2024
2 parents 7690f2c + e9fab46 commit 6b67f99
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/sql/type-guard.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ResultSetHeader, RowDataPacket } from 'mysql2';
import { QueryReturnType } from './types';

function isObjectAResultSetHeader(obj: object): boolean {
function isObjectAResultSetHeader(obj: object): obj is ResultSetHeader {
// test all keys that are present in ResultSetHeader (except deprecated "changedRows")
return (
'fieldCount' in obj &&
Expand Down Expand Up @@ -55,6 +55,11 @@ export function isRowDataPacketArray(
return false;
}

if (obj.length === 0) {
// a result with no data
return true;
}

const firstItem = obj[0];

if (typeof firstItem !== 'object') {
Expand Down

0 comments on commit 6b67f99

Please sign in to comment.