Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: calling .commit causes results to be empty #734

Closed
1 task done
edublancas opened this issue Jul 22, 2023 · 2 comments
Closed
1 task done

[Bug]: calling .commit causes results to be empty #734

edublancas opened this issue Jul 22, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@edublancas
Copy link
Contributor

What happened?

I noticed that calling .commit() on a connection makes existing results empty, this differs from duckdb's native behavior. Is this a bug or some expected behavior?

For context: in JupySQL, we have an autocommit mode that automatically .commit() after executing some SQL query, and I discovered this after debugging some bug reports.

Here's how to reproduce the issue:

import duckdb
duckdb.__version__
'0.8.1'
import duckdb_engine
duckdb_engine.__version__
'0.9.1'
import sqlalchemy
sqlalchemy.__version__
'2.0.19'
conn_native = duckdb.connect()
engine = sqlalchemy.create_engine("duckdb://")
conn_engine = engine.connect()
conn_native.execute("create table my_table (x INT)")
conn_native.execute("insert into my_table (x) VALUES (1), (2), (3)")
results = conn_native.execute("select * from my_table")
conn_native.commit()
print(results.fetchall())
[(1,), (2,), (3,)]
conn_engine.execute(sqlalchemy.text("create table my_table (x INT)"))
conn_engine.execute(sqlalchemy.text("insert into my_table (x) VALUES (1), (2), (3)"))
results = conn_engine.execute(sqlalchemy.text("select * from my_table"))
conn_engine.commit()
print(results.fetchall())
[]

DuckDB Engine Version

0.9.1

DuckDB Version

0.8.1

SQLAlchemy Version

2.0.19

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@edublancas edublancas added the bug Something isn't working label Jul 22, 2023
@Mause
Copy link
Owner

Mause commented Jul 22, 2023

Hey there, the native commit method is a noop if you don't already have a transaction open. If you try the native version with an open transaction, it returns an empty result as well.

Does that help?

@Mause Mause closed this as completed Jul 22, 2023
@Mause Mause reopened this Jul 22, 2023
@edublancas
Copy link
Contributor Author

oh, right! I was able to reproduce this behavior by calling .begin() using the native connection, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants