Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions examples/bun-mysql2/src/db/query_sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export async function getAuthor(client: Client, args: GetAuthorArgs): Promise<Ge
return null;
}
const row = rows[0];
if (!row) {
return null;
}
return {
id: row[0],
name: row[1],
Expand Down Expand Up @@ -168,6 +171,9 @@ export async function test(client: Client): Promise<TestRow | null> {
return null;
}
const row = rows[0];
if (!row) {
return null;
}
return {
cBit: row[0],
cTinyint: row[1],
Expand Down
6 changes: 6 additions & 0 deletions examples/node-mysql2/src/db/query_sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export async function getAuthor(client: Client, args: GetAuthorArgs): Promise<Ge
return null;
}
const row = rows[0];
if (!row) {
return null;
}
return {
id: row[0],
name: row[1],
Expand Down Expand Up @@ -168,6 +171,9 @@ export async function test(client: Client): Promise<TestRow | null> {
return null;
}
const row = rows[0];
if (!row) {
return null;
}
return {
cBit: row[0],
cTinyint: row[1],
Expand Down
11 changes: 11 additions & 0 deletions src/drivers/mysql2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,17 @@ export class Driver {
NodeFlags.TypeExcludesFlags
)
),
factory.createIfStatement(
factory.createPrefixUnaryExpression(
SyntaxKind.ExclamationToken,
factory.createIdentifier("row")
),
factory.createBlock(
[factory.createReturnStatement(factory.createNull())],
true
),
undefined
),
factory.createReturnStatement(
factory.createObjectLiteralExpression(
columns.map((col, i) =>
Expand Down