@@ -24,7 +24,7 @@ describe("v2 transaction integration tests", () => {
2424 await connection . execute ( `
2525 CREATE FACT TABLE IF NOT EXISTS transaction_test (
2626 id LONG,
27- name VARCHAR(100)
27+ name TEXT
2828 )
2929 ` ) ;
3030 } ) ;
@@ -58,7 +58,7 @@ describe("v2 transaction integration tests", () => {
5858 expect ( count ) . toBe ( expected ) ;
5959 } ;
6060
61- it ( "should remove transaction id on commit " , async ( ) => {
61+ it ( "should commit transaction" , async ( ) => {
6262 const firebolt = Firebolt ( {
6363 apiEndpoint : process . env . FIREBOLT_API_ENDPOINT as string
6464 } ) ;
@@ -74,7 +74,7 @@ describe("v2 transaction integration tests", () => {
7474 await checkRecordCountByIdInAnotherTransaction ( 1 , 1 ) ;
7575 } ) ;
7676
77- it ( "should remove transaction id on rollback " , async ( ) => {
77+ it ( "should rollback transaction" , async ( ) => {
7878 const firebolt = Firebolt ( {
7979 apiEndpoint : process . env . FIREBOLT_API_ENDPOINT as string
8080 } ) ;
@@ -90,7 +90,7 @@ describe("v2 transaction integration tests", () => {
9090 await checkRecordCountByIdInAnotherTransaction ( 2 , 0 ) ;
9191 } ) ;
9292
93- it ( "should commit transaction when switching to auto commit " , async ( ) => {
93+ it ( "should commit transaction using transaction control methods " , async ( ) => {
9494 const firebolt = Firebolt ( {
9595 apiEndpoint : process . env . FIREBOLT_API_ENDPOINT as string
9696 } ) ;
@@ -108,47 +108,47 @@ describe("v2 transaction integration tests", () => {
108108 await checkRecordCountByIdInAnotherTransaction ( 3 , 1 ) ;
109109 } ) ;
110110
111- it ( "should handle sequential transactions " , async ( ) => {
111+ it ( "should rollback transaction using transaction control methods " , async ( ) => {
112112 const firebolt = Firebolt ( {
113113 apiEndpoint : process . env . FIREBOLT_API_ENDPOINT as string
114114 } ) ;
115115 const connection = await firebolt . connect ( connectionParams ) ;
116116
117- // First transaction
118117 await connection . begin ( ) ;
118+
119+ // Start transaction
119120 await connection . execute ( "INSERT INTO transaction_test VALUES (4, 'test')" ) ;
120- await checkRecordCountByIdInAnotherTransaction ( 4 , 0 ) ;
121- await connection . commit ( ) ;
122121
123- await checkRecordCountByIdInAnotherTransaction ( 4 , 1 ) ;
122+ await checkRecordCountByIdInAnotherTransaction ( 4 , 0 ) ;
124123
125- // Second transaction
126- await connection . begin ( ) ;
127- await connection . execute ( "INSERT INTO transaction_test VALUES (5, 'test')" ) ;
128- await checkRecordCountByIdInAnotherTransaction ( 5 , 0 ) ;
129- await connection . commit ( ) ;
124+ // Rollback
125+ await connection . rollback ( ) ;
130126
131- await checkRecordCountByIdInAnotherTransaction ( 4 , 1 ) ;
132- await checkRecordCountByIdInAnotherTransaction ( 5 , 1 ) ;
127+ await checkRecordCountByIdInAnotherTransaction ( 4 , 0 ) ;
133128 } ) ;
134129
135- it ( "should rollback transaction successfully " , async ( ) => {
130+ it ( "should handle sequential transactions " , async ( ) => {
136131 const firebolt = Firebolt ( {
137132 apiEndpoint : process . env . FIREBOLT_API_ENDPOINT as string
138133 } ) ;
139134 const connection = await firebolt . connect ( connectionParams ) ;
140135
136+ // First transaction
141137 await connection . begin ( ) ;
138+ await connection . execute ( "INSERT INTO transaction_test VALUES (5, 'test')" ) ;
139+ await checkRecordCountByIdInAnotherTransaction ( 5 , 0 ) ;
140+ await connection . commit ( ) ;
142141
143- // Start transaction
144- await connection . execute ( "INSERT INTO transaction_test VALUES (6, 'test')" ) ;
142+ await checkRecordCountByIdInAnotherTransaction ( 5 , 1 ) ;
145143
144+ // Second transaction
145+ await connection . begin ( ) ;
146+ await connection . execute ( "INSERT INTO transaction_test VALUES (6, 'test')" ) ;
146147 await checkRecordCountByIdInAnotherTransaction ( 6 , 0 ) ;
148+ await connection . commit ( ) ;
147149
148- // Rollback
149- await connection . rollback ( ) ;
150-
151- await checkRecordCountByIdInAnotherTransaction ( 6 , 0 ) ;
150+ await checkRecordCountByIdInAnotherTransaction ( 5 , 1 ) ;
151+ await checkRecordCountByIdInAnotherTransaction ( 6 , 1 ) ;
152152 } ) ;
153153
154154 it ( "should work with prepared statements" , async ( ) => {
@@ -172,7 +172,7 @@ describe("v2 transaction integration tests", () => {
172172 await checkRecordCountByIdInAnotherTransaction ( 7 , 1 ) ;
173173 } ) ;
174174
175- it ( "should not commit transaction when connection closes on auto commit true " , async ( ) => {
175+ it ( "should not commit transaction when connection closes" , async ( ) => {
176176 const firebolt = Firebolt ( {
177177 apiEndpoint : process . env . FIREBOLT_API_ENDPOINT as string
178178 } ) ;
@@ -188,22 +188,6 @@ describe("v2 transaction integration tests", () => {
188188 await checkRecordCountByIdInAnotherTransaction ( 8 , 0 ) ;
189189 } ) ;
190190
191- it ( "should not commit transaction when connection closes on auto commit false" , async ( ) => {
192- const firebolt = Firebolt ( {
193- apiEndpoint : process . env . FIREBOLT_API_ENDPOINT as string
194- } ) ;
195- let connection = await firebolt . connect ( connectionParams ) ;
196-
197- await connection . begin ( ) ;
198- await connection . execute ( "INSERT INTO transaction_test VALUES (9, 'test')" ) ;
199- await checkRecordCountByIdInAnotherTransaction ( 9 , 0 ) ;
200-
201- // Simulate connection close by creating a new connection
202- connection = await firebolt . connect ( connectionParams ) ;
203-
204- await checkRecordCountByIdInAnotherTransaction ( 9 , 0 ) ;
205- } ) ;
206-
207191 it ( "should throw exception when starting transaction during transaction" , async ( ) => {
208192 const firebolt = Firebolt ( {
209193 apiEndpoint : process . env . FIREBOLT_API_ENDPOINT as string
@@ -250,7 +234,7 @@ describe("v2 transaction integration tests", () => {
250234
251235 await connection . begin ( ) ;
252236
253- const createTableSQL = `CREATE FACT TABLE ${ tableName } (id LONG, name VARCHAR(100) )` ;
237+ const createTableSQL = `CREATE FACT TABLE ${ tableName } (id LONG, name TEXT )` ;
254238 const insertSQL = `INSERT INTO ${ tableName } (id, name) VALUES (0, 'some_text')` ;
255239 const checkTableSQL = `SELECT COUNT(*) FROM information_schema.tables WHERE table_name = '${ tableName } '` ;
256240 const selectSQL = `SELECT * FROM ${ tableName } ` ;
@@ -293,7 +277,7 @@ describe("v2 transaction integration tests", () => {
293277
294278 await connection . begin ( ) ;
295279
296- const createTableSQL = `CREATE FACT TABLE ${ tableName } (id LONG, name VARCHAR(100) )` ;
280+ const createTableSQL = `CREATE FACT TABLE ${ tableName } (id LONG, name TEXT )` ;
297281 const insertSQL = `INSERT INTO ${ tableName } (id, name) VALUES (0, 'some_text')` ;
298282 const checkTableSQL = `SELECT COUNT(*) FROM information_schema.tables WHERE table_name = '${ tableName } '` ;
299283
@@ -318,7 +302,7 @@ describe("v2 transaction integration tests", () => {
318302 it ( "should handle parallel transactions" , async ( ) => {
319303 const tableName = "parallel_transactions_test" ;
320304 const dropTableSQL = `DROP TABLE IF EXISTS ${ tableName } CASCADE` ;
321- const createTableSQL = `CREATE FACT TABLE IF NOT EXISTS ${ tableName } (id LONG, name VARCHAR(100) )` ;
305+ const createTableSQL = `CREATE FACT TABLE IF NOT EXISTS ${ tableName } (id LONG, name TEXT )` ;
322306 const insertSQL = `INSERT INTO ${ tableName } (id, name) VALUES (?, ?)` ;
323307 const selectSQL = `SELECT * FROM ${ tableName } ORDER BY id` ;
324308
0 commit comments