fix(db): move query responses to their own try block

Other resources with script errors (notably "attempt to index a nil value") would mistakenly report the query as failed, and people would assume ANY reported errors were because of oxmysql, even through it was their own awful script.

No errors should be thrown in oxmysql when an error occurs in a function reference.
This commit is contained in:
Linden committed 2022-03-07 15:13:07 +11:00
1 parent 7b4ae91dbe
commit afc04fc553
5 files changed
+24 -19

No files matched your search

+1 -1
View File
@@ -12,7 +12,7 @@ const isRowDataPacketArray = (result: QueryResponse): result is RowDataPacket[][
(result as RowDataPacket[][])[0] !== undefined &&
Object.values((result as RowDataPacket[][])[0])[0] !== undefined;
export const parseResponse = (type: QueryType, result: QueryResponse): QueryResponse | number | null => {
export const parseResponse = (type: QueryType, result: QueryResponse): any => {
switch (type) {
case 'insert':
return isOkPacket(result) ? result.insertId : null;