Skip to content

Commit be66048

Browse files
addijhaqau1120thdxr
authored
Support Aliasing (#7)
* update to support aliasing * Update src/data-api-driver.ts Co-authored-by: addison ulhaq <au1120@dexcom.com> Co-authored-by: Dax Raad <d@ironbay.co>
1 parent 11f1a2a commit be66048

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/data-api-driver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class DataApiConnection implements DatabaseConnection {
107107
(rec) =>
108108
Object.fromEntries(
109109
rec.map((val, i) => [
110-
r.columnMetadata![i].name,
110+
r.columnMetadata![i].label || r.columnMetadata![i].name,
111111
val.stringValue ??
112112
val.blobValue ??
113113
val.longValue ??

test/temporary.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ const PERSON = {
1616
last_name: "bezos",
1717
} as const;
1818

19+
const PERSON_ALIAS = {
20+
first: "jeff",
21+
last: "bezos"
22+
}
23+
1924
it("insert and read", async () => {
2025
await db
2126
.insertInto("person")
@@ -30,6 +35,12 @@ it("insert and read", async () => {
3035
expect(result[0]).toMatchObject(PERSON);
3136
});
3237

38+
it("alias return", async () => {
39+
const result = await db.selectFrom("person").select(["first_name as first", "last_name as last"]).execute();
40+
expect(result).toHaveLength(1);
41+
expect(result[0]).toMatchObject(PERSON_ALIAS);
42+
});
43+
3344
it("join", async () => {
3445
const person = await db
3546
.insertInto("person")

0 commit comments

Comments
 (0)