@@ -378,6 +378,54 @@ def test_execute_many(self):
378378 self .assertEqual (res [0 ], 1 )
379379 conn .close ()
380380
381+ def test_DDL_autocommit (self ):
382+ """Check that DDLs in autocommit mode are immediately executed."""
383+ conn = Connection (Config .INSTANCE , self ._db )
384+ conn .autocommit = True
385+
386+ cur = conn .cursor ()
387+ cur .execute (
388+ """
389+ CREATE TABLE Singers (
390+ SingerId INT64 NOT NULL,
391+ Name STRING(1024),
392+ ) PRIMARY KEY (SingerId)
393+ """
394+ )
395+ conn .close ()
396+
397+ # if previous DDL wasn't committed, the next DROP TABLE
398+ # statement will fail with a ProgrammingError
399+ conn = Connection (Config .INSTANCE , self ._db )
400+ cur = conn .cursor ()
401+
402+ cur .execute ("DROP TABLE Singers" )
403+ conn .commit ()
404+
405+ def test_DDL_commit (self ):
406+ """Check that DDLs in commit mode are executed on calling `commit()`."""
407+ conn = Connection (Config .INSTANCE , self ._db )
408+ cur = conn .cursor ()
409+
410+ cur .execute (
411+ """
412+ CREATE TABLE Singers (
413+ SingerId INT64 NOT NULL,
414+ Name STRING(1024),
415+ ) PRIMARY KEY (SingerId)
416+ """
417+ )
418+ conn .commit ()
419+ conn .close ()
420+
421+ # if previous DDL wasn't committed, the next DROP TABLE
422+ # statement will fail with a ProgrammingError
423+ conn = Connection (Config .INSTANCE , self ._db )
424+ cur = conn .cursor ()
425+
426+ cur .execute ("DROP TABLE Singers" )
427+ conn .commit ()
428+
381429
382430def clear_table (transaction ):
383431 """Clear the test table."""
0 commit comments