Skip to content

Commit

Permalink
hotfix: hot fix the remote server query does not show proper result
Browse files Browse the repository at this point in the history
  • Loading branch information
invisal committed Mar 22, 2024
1 parent 3fd4451 commit e36421a
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/drivers/remote-driver.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InStatement, ResultSet } from "@libsql/client/web";
import { InStatement, ResultSet, Row } from "@libsql/client/web";
import {
BaseDriver,
DatabaseSchemaItem,
Expand All @@ -15,6 +15,20 @@ import {
} from "@/lib/api-response-types";
import { RequestOperationBody } from "@/lib/api/api-request-types";

export function transformRawResult(raw: ResultSet): ResultSet {
const r = {
...raw,
rows: raw.rows.map((r) =>
raw.columns.reduce((a, b, idx) => {
a[b] = r[idx];
return a;
}, {} as Row)
),
};

return r;
}

export default class RemoteDriver implements BaseDriver {
protected id: string = "";
protected authToken = "";
Expand Down Expand Up @@ -52,7 +66,7 @@ export default class RemoteDriver implements BaseDriver {
statement: stmt,
});

return r.data;
return transformRawResult(r.data);
}

async transaction(stmt: InStatement[]) {
Expand All @@ -61,7 +75,7 @@ export default class RemoteDriver implements BaseDriver {
statements: stmt,
});

return r.data;
return r.data.map(transformRawResult);
}

close() {}
Expand Down

0 comments on commit e36421a

Please sign in to comment.