@@ -46,17 +46,6 @@ def __init__(self, connection, isolation, readonly, deferrable):
46
46
'isolation is expected to be either of {}, '
47
47
'got {!r}' .format (ISOLATION_LEVELS , isolation ))
48
48
49
- if isolation and isolation != 'serializable' :
50
- if readonly :
51
- raise ValueError (
52
- '"readonly" is only supported for '
53
- 'serializable transactions' )
54
-
55
- if deferrable and not readonly :
56
- raise ValueError (
57
- '"deferrable" is only supported for '
58
- 'serializable readonly transactions' )
59
-
60
49
self ._isolation = isolation
61
50
self ._readonly = readonly
62
51
self ._deferrable = deferrable
@@ -132,19 +121,18 @@ async def start(self):
132
121
self ._id = con ._get_unique_id ('savepoint' )
133
122
query = 'SAVEPOINT {};' .format (self ._id )
134
123
else :
135
- if self ._isolation is None :
136
- query = 'BEGIN;'
137
- elif self ._isolation == 'read_committed' :
138
- query = 'BEGIN ISOLATION LEVEL READ COMMITTED;'
124
+ query = 'BEGIN'
125
+ if self ._isolation == 'read_committed' :
126
+ query += ' ISOLATION LEVEL READ COMMITTED'
139
127
elif self ._isolation == 'repeatable_read' :
140
- query = 'BEGIN ISOLATION LEVEL REPEATABLE READ; '
141
- else :
142
- query = 'BEGIN ISOLATION LEVEL SERIALIZABLE'
143
- if self ._readonly :
144
- query += ' READ ONLY'
145
- if self ._deferrable :
146
- query += ' DEFERRABLE'
147
- query += ';'
128
+ query + = ' ISOLATION LEVEL REPEATABLE READ'
129
+ elif self . _isolation == 'serializable' :
130
+ query + = ' ISOLATION LEVEL SERIALIZABLE'
131
+ if self ._readonly :
132
+ query += ' READ ONLY'
133
+ if self ._deferrable :
134
+ query += ' DEFERRABLE'
135
+ query += ';'
148
136
149
137
try :
150
138
await self ._connection .execute (query )
0 commit comments