@@ -238,9 +238,6 @@ export function queriesTests() {
238238
239239 const countRes = await db . execute ( 'SELECT COUNT(*) as count FROM User' ) ;
240240
241- // console.log(countRes);
242-
243- // expect(countRes.metadata?.[0]?.type).to.equal('UNKNOWN');
244241 expect ( countRes . rows ?. length ) . to . equal ( 1 ) ;
245242 expect ( countRes . rows ?. [ 0 ] ?. count ) . to . equal ( 1 ) ;
246243
@@ -257,18 +254,14 @@ export function queriesTests() {
257254
258255 const sumRes = await db . execute ( 'SELECT SUM(age) as sum FROM User;' ) ;
259256
260- // expect(sumRes.metadata?.[0]?.type).to.equal('UNKNOWN');
261257 expect ( sumRes . rows [ 0 ] ! . sum ) . to . equal ( age + age2 ) ;
262258
263- // MAX(networth), MIN(networth)
264259 const maxRes = await db . execute (
265260 'SELECT MAX(networth) as `max` FROM User;' ,
266261 ) ;
267262 const minRes = await db . execute (
268263 'SELECT MIN(networth) as `min` FROM User;' ,
269264 ) ;
270- // expect(maxRes.metadata?.[0]?.type).to.equal('UNKNOWN');
271- // expect(minRes.metadata?.[0]?.type).to.equal('UNKNOWN');
272265 const maxNetworth = Math . max ( networth , networth2 ) ;
273266 const minNetworth = Math . min ( networth , networth2 ) ;
274267
@@ -707,6 +700,32 @@ export function queriesTests() {
707700 await db . execute ( 'SELECT ?; ' , [ 1 ] ) ;
708701 } ) ;
709702
703+ it ( 'Handles concurrent transactions correctly' , async ( ) => {
704+ const id = chance . integer ( ) ;
705+ const name = chance . name ( ) ;
706+ const age = chance . integer ( ) ;
707+ const networth = chance . floating ( ) ;
708+
709+ const transaction1 = db . transaction ( async tx => {
710+ await tx . execute (
711+ 'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)' ,
712+ [ id , name , age , networth ] ,
713+ ) ;
714+ } ) ;
715+
716+ const transaction2 = db . transaction ( async tx => {
717+ await tx . execute (
718+ 'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)' ,
719+ [ id + 1 , name , age , networth ] ,
720+ ) ;
721+ } ) ;
722+
723+ await Promise . all ( [ transaction1 , transaction2 ] ) ;
724+
725+ const res = await db . execute ( 'SELECT * FROM User' ) ;
726+ expect ( res . rows . length ) . to . equal ( 2 ) ;
727+ } ) ;
728+
710729 it ( 'Pragma user_version' , ( ) => {
711730 const res = db . executeSync ( 'PRAGMA user_version' ) ;
712731 console . warn ( res . rows ) ;
0 commit comments