Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tools/pythonpkg/src/native/python_objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,8 @@ py::object PythonObject::FromValue(const Value &val, const LogicalType &type,
auto &child_entry = child_types[i];
auto &child_name = child_entry.first;
auto &child_type = child_entry.second;
py_struct[child_name.c_str()] = FromValue(struct_values[i], child_type, client_properties);
auto name = child_name.empty() ? StringUtil::Format("v%d", i) : child_name;
py_struct[name.c_str()] = FromValue(struct_values[i], child_type, client_properties);
}
return std::move(py_struct);
}
Expand Down
4 changes: 4 additions & 0 deletions tools/pythonpkg/tests/fast/api/test_dbapi_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,7 @@ def test_fetch_one_relation(self, duckdb_cursor):
assert res.fetchone() == (1,)
assert res.fetchone() == (2,)
assert res.fetchone() is None

def test_fetch_unnamed_struct(self, duckdb_cursor):
res = duckdb_cursor.query("select (1, 2)").fetchall()
assert res == [({'v0': 1, 'v1': 2},)]