Skip to content

Commit

Permalink
fix: Restore internal use of transactions instead of savepoints, beca…
Browse files Browse the repository at this point in the history
…use 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.
  • Loading branch information
jpmckinney committed Jan 9, 2024
1 parent a742893 commit 8f120be
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
0.7.1 - Jan 9, 2024
--------------------

* fix: Restore internal use of transactions instead of savepoints, because not all database engines support savepoints.

0.7.0 - Oct 18, 2023
--------------------

Expand Down
7 changes: 2 additions & 5 deletions agatesql/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,15 +276,14 @@ def to_sql(self, connection_or_string, table_name, overwrite=False,
min_col_len=min_col_len, col_len_multiplier=col_len_multiplier)

if create:
with connection.begin_nested() as conn:
with connection.begin() as conn:
if overwrite:
sql_table.drop(bind=connection, checkfirst=True)

sql_table.create(bind=connection, checkfirst=create_if_not_exists)
conn.commit()

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

conn.commit()

try:
return sql_table
finally:
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

project = 'agate-sql'
copyright = '2017, Christopher Groskopf'
version = '0.7.0'
version = '0.7.1'
release = version

# -- General configuration ---------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name='agate-sql',
version='0.7.0',
version='0.7.1',
description='agate-sql adds SQL read/write support to agate.',
long_description=long_description,
long_description_content_type='text/x-rst',
Expand Down

0 comments on commit 8f120be

Please sign in to comment.