@@ -249,7 +249,7 @@ public void ImplicitSession_ConcurrentCommand_IsStillBlockedByBusyCheck()
249249 }
250250
251251 [ Fact ]
252- public async Task ImplicitSession_WithExplicitTransaction_UsesExplicitSessionAndCommits ( )
252+ public async Task ImplicitSession_DisallowsTransactions_And_AllowsNonTransactionalCommands ( )
253253 {
254254 var table = $ "Implicit_{ Guid . NewGuid ( ) : N} ";
255255
@@ -271,23 +271,27 @@ PRIMARY KEY (Id)
271271 await create . ExecuteNonQueryAsync ( ) ;
272272 }
273273
274- var tx = connection . BeginTransaction ( ) ;
275274 await using ( var insert = connection . CreateCommand ( ) )
276275 {
277- insert . Transaction = tx ;
278276 insert . CommandText = $ "INSERT INTO { table } (Id, Name) VALUES (1, 'A');";
279277 await insert . ExecuteNonQueryAsync ( ) ;
280- insert . CommandText = $ "INSERT INTO { table } (Id, Name) VALUES (2, 'B');";
281- await insert . ExecuteNonQueryAsync ( ) ;
282278 }
283279
284- await tx . CommitAsync ( ) ;
280+ var tx = connection . BeginTransaction ( ) ;
281+ await using ( var insertTx = connection . CreateCommand ( ) )
282+ {
283+ insertTx . Transaction = tx ;
284+ insertTx . CommandText = $ "INSERT INTO { table } (Id, Name) VALUES (2, 'B');";
285+ var ex = await Assert . ThrowsAsync < YdbException > ( async ( ) => await insertTx . ExecuteNonQueryAsync ( ) ) ;
286+ Assert . Contains ( "Transactions are not supported in implicit sessions" , ex . Message ) ;
287+ }
288+ await tx . RollbackAsync ( ) ;
285289
286290 await using ( var check = connection . CreateCommand ( ) )
287291 {
288292 check . CommandText = $ "SELECT COUNT(*) FROM { table } ;";
289293 var count = Convert . ToInt32 ( await check . ExecuteScalarAsync ( ) ) ;
290- Assert . Equal ( 2 , count ) ;
294+ Assert . Equal ( 1 , count ) ;
291295 }
292296 }
293297 finally
0 commit comments