Skip to content

Commit 018e64e

Browse files
author
Jakub Urban
committed
added test_column_names
1 parent f86bd5a commit 018e64e

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/test_databases.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,3 +802,26 @@ async def test_iterate_outside_transaction_with_temp_table(database_url):
802802
iterate_results.append(result)
803803

804804
assert len(iterate_results) == 5
805+
806+
807+
@pytest.mark.parametrize("database_url", DATABASE_URLS)
808+
@pytest.mark.parametrize("select_query", [notes.select(), "SELECT * FROM notes"])
809+
@async_adapter
810+
async def test_column_names(database_url, select_query):
811+
"""
812+
Test that the basic `execute()`, `execute_many()`, `fetch_all()``, and
813+
`fetch_one()` interfaces are all supported (using SQLAlchemy core).
814+
"""
815+
async with Database(database_url) as database:
816+
async with database.transaction(force_rollback=True):
817+
# insert values
818+
query = notes.insert()
819+
values = {"text": "example1", "completed": True}
820+
await database.execute(query, values)
821+
# fetch results
822+
results = await database.fetch_all(query=select_query)
823+
assert len(results) == 1
824+
825+
assert sorted(results[0].keys()) == ["completed", "id", "text"]
826+
assert results[0]["text"] == "example1"
827+
assert results[0]["completed"] == True

0 commit comments

Comments
 (0)