Skip to content

Commit a552fab

Browse files
committed
Updates for latest version
1 parent 3c66709 commit a552fab

4 files changed

Lines changed: 35 additions & 18 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"esbuild": "^0.13.6",
2727
"esbuild-runner": "^2.2.1",
2828
"jest": "^27.2.5",
29-
"kysely": "^0.7.7",
29+
"kysely": "^0.16.5",
3030
"perf_hooks": "^0.0.1"
3131
},
3232
"peerDependencies": {

src/data-api-driver.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,26 @@ export class DataApiDriver implements Driver {
2424
}
2525

2626
async beginTransaction(conn: DataApiConnection) {
27+
if ("connection" in conn) {
28+
await (conn as any).connection.beginTransaction();
29+
return;
30+
}
2731
await conn.beginTransaction();
2832
}
2933

3034
async commitTransaction(conn: DataApiConnection) {
35+
if ("connection" in conn) {
36+
await (conn as any).connection.commitTransaction();
37+
return;
38+
}
3139
await conn.commitTransaction();
3240
}
3341

3442
async rollbackTransaction(conn: DataApiConnection) {
43+
if ("connection" in conn) {
44+
await (conn as any).connection.rollbackTransaction();
45+
return;
46+
}
3547
await conn.rollbackTransaction();
3648
}
3749

@@ -48,7 +60,7 @@ class DataApiConnection implements DatabaseConnection {
4860
this.#config = config;
4961
}
5062

51-
async beginTransaction() {
63+
public async beginTransaction() {
5264
const r = await this.#config.client
5365
.beginTransaction({
5466
secretArn: this.#config.secretArn,
@@ -59,7 +71,7 @@ class DataApiConnection implements DatabaseConnection {
5971
this.#transactionId = r.transactionId;
6072
}
6173

62-
async commitTransaction() {
74+
public async commitTransaction() {
6375
if (!this.#transactionId)
6476
throw new Error("Cannot commit a transaction before creating it");
6577
await this.#config.client
@@ -71,7 +83,7 @@ class DataApiConnection implements DatabaseConnection {
7183
.promise();
7284
}
7385

74-
async rollbackTransaction() {
86+
public async rollbackTransaction() {
7587
if (!this.#transactionId)
7688
throw new Error("Cannot rollback a transaction before creating it");
7789
await this.#config.client
@@ -90,14 +102,14 @@ class DataApiConnection implements DatabaseConnection {
90102
secretArn: this.#config.secretArn,
91103
resourceArn: this.#config.resourceArn,
92104
sql: compiledQuery.sql,
93-
parameters: compiledQuery.bindings as any,
105+
parameters: compiledQuery.parameters as any,
94106
database: this.#config.database,
95107
includeResultMetadata: true,
96108
})
97109
.promise();
98110
if (!r.columnMetadata) {
99111
return {
100-
numUpdatedOrDeletedRows: r.numberOfRecordsUpdated,
112+
numUpdatedOrDeletedRows: BigInt(r.numberOfRecordsUpdated || 0),
101113
rows: [],
102114
};
103115
}

src/data-api-query-compiler.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,31 @@ import { MysqlQueryCompiler, PostgresQueryCompiler } from "kysely";
33

44
export class PostgresDataApiQueryCompiler extends PostgresQueryCompiler {
55
protected override appendValue(value: any) {
6-
const name = this.numBindings;
6+
const name = this.numParameters;
77
this.append(this.getCurrentParameterPlaceholder());
8-
this.addBinding({
8+
this.addParameter({
99
name: name.toString(),
1010
value: serialize(value),
1111
});
1212
}
1313

1414
protected override getCurrentParameterPlaceholder() {
15-
return ":" + this.numBindings;
15+
return ":" + this.numParameters;
1616
}
1717
}
1818

1919
export class MysqlDataApiQueryCompiler extends MysqlQueryCompiler {
2020
protected override appendValue(value: any) {
21-
const name = this.numBindings;
21+
const name = this.numParameters;
2222
this.append(this.getCurrentParameterPlaceholder());
23-
this.addBinding({
23+
this.addParameter({
2424
name: name.toString(),
2525
value: serialize(value),
2626
});
2727
}
2828

2929
protected override getCurrentParameterPlaceholder() {
30-
return ":" + this.numBindings;
30+
return ":" + this.addParameter;
3131
}
3232
}
3333

yarn.lock

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -578,11 +578,16 @@
578578
jest-diff "^27.0.0"
579579
pretty-format "^27.0.0"
580580

581-
"@types/node@*", "@types/node@^16.10.9", "@types/node@^16.11.0":
581+
"@types/node@*", "@types/node@^16.11.0":
582582
version "16.11.0"
583583
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.0.tgz#4b95f2327bacd1ef8f08d8ceda193039c5d7f52e"
584584
integrity sha512-8MLkBIYQMuhRBQzGN9875bYsOhPnf/0rgXGo66S2FemHkhbn9qtsz9ywV1iCG+vbjigE4WUNVvw37Dx+L0qsPg==
585585

586+
"@types/node@^16.11.9":
587+
version "16.11.19"
588+
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.19.tgz#1afa165146997b8286b6eabcb1c2d50729055169"
589+
integrity sha512-BPAcfDPoHlRQNKktbsbnpACGdypPFBuX4xQlsWDE7B8XXcfII+SpOLay3/qZmCLb39kV5S1RTYwXdkx2lwLYng==
590+
586591
"@types/prettier@^2.1.5":
587592
version "2.4.1"
588593
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.4.1.tgz#e1303048d5389563e130f5bdd89d37a99acb75eb"
@@ -2003,12 +2008,12 @@ kleur@^3.0.3:
20032008
resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e"
20042009
integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==
20052010

2006-
kysely@^0.7.7:
2007-
version "0.7.7"
2008-
resolved "https://registry.yarnpkg.com/kysely/-/kysely-0.7.7.tgz#7812f834be5c63c273dcdf1907afec7804813ee5"
2009-
integrity sha512-CVOmPJRkkU9Gsn5YXuuV/RS/0UsEhcP+/C3MV2durH21iGHIkJzxpUIf0ykVdrih6oUhw6wj2FbBSOkVglMR+A==
2011+
kysely@^0.16.5:
2012+
version "0.16.5"
2013+
resolved "https://registry.yarnpkg.com/kysely/-/kysely-0.16.5.tgz#e163040352b8c6f5e6f93f3f82b633faa247ccc2"
2014+
integrity sha512-rzjbUZ6X17x+gTcY0KdsijkmyF4yGvNeEjJ6c1ARG/8cUMMAU69KjUBKRdj3YhxzLXvr+yct/kAIPOw+F/kF0A==
20102015
dependencies:
2011-
"@types/node" "^16.10.9"
2016+
"@types/node" "^16.11.9"
20122017

20132018
leven@^3.1.0:
20142019
version "3.1.0"

0 commit comments

Comments
 (0)