Skip to content

Commit 8f120be

Browse files
committed
fix: Restore internal use of transactions instead of savepoints, because not all database engines support savepoints
91276ae changed this in case calling code had started a transaction - but it also added an explicit COMMIT, which commits the outermost transaction, which is unexpected by calling code.
1 parent a742893 commit 8f120be

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

CHANGELOG.rst

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
0.7.1 - Jan 9, 2024
2+
--------------------
3+
4+
* fix: Restore internal use of transactions instead of savepoints, because not all database engines support savepoints.
5+
16
0.7.0 - Oct 18, 2023
27
--------------------
38

agatesql/table.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -276,15 +276,14 @@ def to_sql(self, connection_or_string, table_name, overwrite=False,
276276
min_col_len=min_col_len, col_len_multiplier=col_len_multiplier)
277277

278278
if create:
279-
with connection.begin_nested() as conn:
279+
with connection.begin() as conn:
280280
if overwrite:
281281
sql_table.drop(bind=connection, checkfirst=True)
282282

283283
sql_table.create(bind=connection, checkfirst=create_if_not_exists)
284-
conn.commit()
285284

286285
if insert:
287-
with connection.begin_nested() as conn:
286+
with connection.begin() as conn:
288287
insert = sql_table.insert()
289288
for prefix in prefixes:
290289
insert = insert.prefix_with(prefix)
@@ -299,8 +298,6 @@ def to_sql(self, connection_or_string, table_name, overwrite=False,
299298
connection.execute(insert, [dict(zip(self.column_names, row)) for row in
300299
self.rows[index * chunk_size:end_index]])
301300

302-
conn.commit()
303-
304301
try:
305302
return sql_table
306303
finally:

docs/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
project = 'agate-sql'
1414
copyright = '2017, Christopher Groskopf'
15-
version = '0.7.0'
15+
version = '0.7.1'
1616
release = version
1717

1818
# -- General configuration ---------------------------------------------------

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name='agate-sql',
8-
version='0.7.0',
8+
version='0.7.1',
99
description='agate-sql adds SQL read/write support to agate.',
1010
long_description=long_description,
1111
long_description_content_type='text/x-rst',

0 commit comments

Comments
 (0)