fix postgres raw query result

This commit is contained in:
2024-07-14 20:49:57 +02:00
parent 2ca70ec1a5
commit d9a01fbd83
3 changed files with 61 additions and 36 deletions

View File

@@ -348,13 +348,18 @@ export class PostgresDriver implements Driver {
const sql = await this.queryRunner(credentials);
const result = await sql.unsafe(query);
void sql.end();
return {
count: result.length,
data: result,
};
if ("count" in result && result.count !== undefined) {
return [
{
count: result.count,
data: result,
},
];
}
return result.map((row) => ({
count: row.count,
data: row,
}));
}
}