@@ -2490,89 +2490,6 @@ public function testStartTransactionCommand() {
24902490 $ this ->assertCount ( 0 , $ this ->engine ->get_query_results () );
24912491 }
24922492
2493- public function testNestedTransactionWork () {
2494- $ this ->assertQuery ( 'BEGIN ' );
2495- $ this ->assertQuery ( "INSERT INTO _options (option_name) VALUES ('first'); " );
2496- $ this ->assertQuery ( 'START TRANSACTION ' );
2497- $ this ->assertQuery ( "INSERT INTO _options (option_name) VALUES ('second'); " );
2498- $ this ->assertQuery ( 'START TRANSACTION ' );
2499- $ this ->assertQuery ( "INSERT INTO _options (option_name) VALUES ('third'); " );
2500- $ this ->assertQuery ( 'SELECT * FROM _options; ' );
2501- $ this ->assertCount ( 3 , $ this ->engine ->get_query_results () );
2502-
2503- $ this ->assertQuery ( 'ROLLBACK ' );
2504- $ this ->assertQuery ( 'SELECT * FROM _options; ' );
2505- $ this ->assertCount ( 2 , $ this ->engine ->get_query_results () );
2506-
2507- $ this ->assertQuery ( 'ROLLBACK ' );
2508- $ this ->assertQuery ( 'SELECT * FROM _options; ' );
2509- $ this ->assertCount ( 1 , $ this ->engine ->get_query_results () );
2510-
2511- $ this ->assertQuery ( 'COMMIT ' );
2512- $ this ->assertQuery ( 'SELECT * FROM _options; ' );
2513- $ this ->assertCount ( 1 , $ this ->engine ->get_query_results () );
2514- }
2515-
2516- public function testNestedTransactionWorkComplexModify () {
2517- $ this ->assertQuery ( 'BEGIN ' );
2518- // Create a complex ALTER Table query where the first
2519- // column is added successfully, but the second fails.
2520- // Behind the scenes, this single MySQL query is split
2521- // into multiple SQLite queries – some of them will
2522- // succeed, some will fail.
2523- $ error = '' ;
2524- try {
2525- $ this ->engine ->query (
2526- '
2527- ALTER TABLE _options
2528- ADD COLUMN test varchar(20),
2529- ADD COLUMN test varchar(20)
2530- '
2531- );
2532- } catch ( Throwable $ e ) {
2533- $ error = $ e ->getMessage ();
2534- }
2535- $ this ->assertStringContainsString ( "Duplicate column name 'test' " , $ error );
2536-
2537- // Commit the transaction.
2538- $ this ->assertQuery ( 'COMMIT ' );
2539-
2540- // Confirm the entire query failed atomically and no column was
2541- // added to the table.
2542- $ this ->assertQuery ( 'DESCRIBE _options; ' );
2543- $ fields = $ this ->engine ->get_query_results ();
2544-
2545- $ this ->assertEquals (
2546- array (
2547- (object ) array (
2548- 'Field ' => 'ID ' ,
2549- 'Type ' => 'int ' ,
2550- 'Null ' => 'NO ' ,
2551- 'Key ' => 'PRI ' ,
2552- 'Default ' => null ,
2553- 'Extra ' => 'auto_increment ' ,
2554- ),
2555- (object ) array (
2556- 'Field ' => 'option_name ' ,
2557- 'Type ' => 'text ' ,
2558- 'Null ' => 'NO ' ,
2559- 'Key ' => '' ,
2560- 'Default ' => '' ,
2561- 'Extra ' => '' ,
2562- ),
2563- (object ) array (
2564- 'Field ' => 'option_value ' ,
2565- 'Type ' => 'text ' ,
2566- 'Null ' => 'NO ' ,
2567- 'Key ' => '' ,
2568- 'Default ' => '' ,
2569- 'Extra ' => '' ,
2570- ),
2571- ),
2572- $ fields
2573- );
2574- }
2575-
25762493 public function testCount () {
25772494 $ this ->assertQuery ( "INSERT INTO _options (option_name) VALUES ('first'); " );
25782495 $ this ->assertQuery ( "INSERT INTO _options (option_name) VALUES ('second'); " );
0 commit comments