Skip to content

Commit a9c2915

Browse files
committed
fix: Changing the commit Sequence
1 parent b69461e commit a9c2915

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

sqlalchemy_database/database.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ async def execute(
4949
) -> Union[Result, _T]:
5050
async with self.session_maker() as session:
5151
result = await session.execute(statement, params, execution_options, bind_arguments, **kw)
52-
if commit:
53-
await session.commit()
5452
if on_close_pre:
5553
result = on_close_pre(result)
54+
if commit:
55+
await session.commit()
5656
return result
5757

5858
async def scalar(
@@ -128,10 +128,10 @@ async def run_sync(
128128
maker = self.session_maker if is_session else self.engine.connect
129129
async with maker() as conn:
130130
result = await conn.run_sync(fn, *args, **kwargs)
131-
if commit:
132-
await conn.commit()
133131
if on_close_pre:
134132
result = on_close_pre(result)
133+
if commit:
134+
await conn.commit()
135135
return result
136136

137137

@@ -166,10 +166,10 @@ def execute(
166166
) -> Union[Result, _T]:
167167
with self.session_maker() as session:
168168
result = session.execute(statement, params, execution_options, bind_arguments, **kw)
169-
if commit:
170-
session.commit()
171169
if on_close_pre:
172170
result = on_close_pre(result)
171+
if commit:
172+
session.commit()
173173
return result
174174

175175
def scalar(
@@ -246,8 +246,8 @@ def run_sync(
246246
maker = self.session_maker if is_session else self.engine.connect
247247
with maker() as conn:
248248
result = fn(conn, *args, **kwargs)
249-
if commit:
250-
conn.commit()
251249
if on_close_pre:
252250
result = on_close_pre(result)
251+
if commit:
252+
conn.commit()
253253
return result

0 commit comments

Comments
 (0)