@@ -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 }
0 commit comments