@@ -7948,6 +7948,48 @@ async def test_edgeql_insert_empty_array_05(self):
79487948 [{'l2' : 0 , 'subordinates' : [{'name' : 'hi' , '@comment' : 'a' }]}],
79497949 )
79507950
7951+ async def test_edgeql_insert_read_only_tx_01 (self ):
7952+ con = (
7953+ edgedb .create_async_client (
7954+ ** self .get_connect_args (database = self .con .dbname )
7955+ ).with_transaction_options (
7956+ edgedb .TransactionOptions (readonly = True )
7957+ )
7958+ )
7959+ try :
7960+ with self .assertRaisesRegex (
7961+ edgedb .TransactionError ,
7962+ r'Modifications not allowed in a read-only transaction'
7963+ ):
7964+ async for tx in con .transaction ():
7965+ async with tx :
7966+ await tx .execute ("insert Subordinate { name := 'hi' }" )
7967+ finally :
7968+ await con .aclose ()
7969+
7970+ async def test_edgeql_insert_read_only_tx_02 (self ):
7971+ # Check that the error is raised if the query is cached.
7972+
7973+ await self .con .execute ("insert Subordinate { name := 'hi' }" )
7974+
7975+ con = (
7976+ edgedb .create_async_client (
7977+ ** self .get_connect_args (database = self .con .dbname )
7978+ ).with_transaction_options (
7979+ edgedb .TransactionOptions (readonly = True )
7980+ )
7981+ )
7982+ try :
7983+ with self .assertRaisesRegex (
7984+ edgedb .TransactionError ,
7985+ r'Modifications not allowed in a read-only transaction'
7986+ ):
7987+ async for tx in con .transaction ():
7988+ async with tx :
7989+ await tx .execute ("insert Subordinate { name := 'hi' }" )
7990+ finally :
7991+ await con .aclose ()
7992+
79517993
79527994class TestRepeatableReadInsert (tb .QueryTestCase ):
79537995 '''The scope of the tests is testing various modes of Object creation.'''
0 commit comments