Compare commits

..

No commits in common. "687494727bfa8e3309a3c04969c8e70c21ec56dc" and "f70d15583c8bf122df5643f34ae2fad786822d80" have entirely different histories.

2 changed files with 6 additions and 6 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@navy.gif/wrappers",
"version": "1.3.7",
"version": "1.3.5",
"description": "Various wrapper classes I use in my projects",
"repository": "https://git.corgi.wtf/Navy.gif/wrappers.git",
"author": "Navy.gif",

View File

@ -175,10 +175,10 @@ class MariaDB {
* @throws {MariaError}
* @private
* */
async #_query<T> (query: string, values: (string | number | string[] | number[])[], timeout?: number, attempts = 0): Promise<T[] | FieldInfo[]> {
async #_query (query: string, values: (string | number | string[] | number[])[], timeout?: number, attempts = 0): Promise<object[] | FieldInfo[] | null> {
const connection = await this.getConnection();
try {
const result = await new Promise<T[] | FieldInfo[] | undefined>((resolve, reject) => {
const result = await new Promise<object[] | FieldInfo[] | undefined>((resolve, reject) => {
const q = connection.query({ timeout, sql: query }, values, (err, results, fields) => {
if (err)
reject(err);
@ -190,7 +190,7 @@ class MariaDB {
});
this.#logger.debug(`Constructed query: ${q.sql}`);
});
return Promise.resolve(result || []);
return Promise.resolve(result ?? null);
} catch (err) {
const error = err as MariaError;
// Retry safe errors // (Galera) Instance not ready for query
@ -200,7 +200,7 @@ class MariaDB {
}
}
async query<T> (query: string, values: (string | number | string[] | number[])[], timeout?: number): Promise<T[] | FieldInfo[]> {
async query (query: string, values: (string | number | string[] | number[])[], timeout?: number) {
if (!this.ready)
return Promise.reject(new Error('MariaDB not ready'));
@ -210,7 +210,7 @@ class MariaDB {
batch = values.some(val => val instanceof Array);
this.#logger.debug(`Incoming query (batch: ${batch})\n${query}\n${inspect(values)}`);
return this.#_query<T>(query, values, timeout);
return this.#_query(query, values, timeout);
}