@@ -36,8 +36,8 @@ describe('Transaction', () => {
3636
3737 it ( 'should create a client with an empty temp table' , async ( ) => {
3838 await withClient ( async ( client ) => {
39- const { rowCount } = await client . query ( 'SELECT * FROM test_table' )
40- assert . equal ( rowCount , 0 , 'Temp table should be empty on creation' )
39+ const { rows } = await client . query ( 'SELECT * FROM test_table' )
40+ assert . equal ( rows . length , 0 , 'Temp table should be empty on creation' )
4141 } )
4242 } )
4343
@@ -51,15 +51,15 @@ describe('Transaction', () => {
5151
5252 // while inside this transaction, the changes are not visible outside
5353 await withClient ( async ( innerClient ) => {
54- const { rowCount } = await innerClient . query ( 'SELECT * FROM test_table' )
55- assert . equal ( rowCount , 0 , 'Temp table should still be empty inside transaction' )
54+ const { rows } = await innerClient . query ( 'SELECT * FROM test_table' )
55+ assert . equal ( rows . length , 0 , 'Temp table should still be empty inside transaction' )
5656 } )
57+ } )
5758
58- // now that the transaction is committed, the changes are visible outside
59- await withClient ( async ( innerClient ) => {
60- const { rowCount } = await innerClient . query ( 'SELECT * FROM test_table' )
61- assert . equal ( rowCount , 1 , 'Row should be inserted after transaction commits' )
62- } )
59+ // now that the transaction is committed, the changes are visible outside
60+ await withClient ( async ( innerClient ) => {
61+ const { rows } = await innerClient . query ( 'SELECT * FROM test_table' )
62+ assert . equal ( rows . length , 1 , 'Row should be inserted after transaction commits' )
6363 } )
6464 } )
6565 } )
@@ -76,8 +76,8 @@ describe('Transaction', () => {
7676 }
7777
7878 // After rollback, the table should still be empty
79- const { rowCount } = await client . query ( 'SELECT * FROM test_table' )
80- assert . equal ( rowCount , 0 , 'Temp table should be empty after rollback' )
79+ const { rows } = await client . query ( 'SELECT * FROM test_table' )
80+ assert . equal ( rows . length , 0 , 'Temp table should be empty after rollback' )
8181 } )
8282 } )
8383
@@ -113,8 +113,8 @@ describe('Transaction', () => {
113113 }
114114
115115 // After rollback, the table should still be empty
116- const { rowCount } = await pool . query ( 'SELECT * FROM test_table' )
117- assert . equal ( rowCount , 0 , 'Temp table should be empty after pool rollback' )
116+ const { rows } = await pool . query ( 'SELECT * FROM test_table' )
117+ assert . equal ( rows . length , 0 , 'Temp table should be empty after pool rollback' )
118118 } finally {
119119 await pool . end ( )
120120 }
0 commit comments