diff --git a/external/duckdb b/external/duckdb index 7ce99bc0..95fcb8f1 160000 --- a/external/duckdb +++ b/external/duckdb @@ -1 +1 @@ -Subproject commit 7ce99bc04130615dfc3a39dfb79177a8942fefba +Subproject commit 95fcb8f18819b1a77df079a7fcb753a8c2f52844 diff --git a/src/duckdb_py/include/duckdb_python/pyrelation.hpp b/src/duckdb_py/include/duckdb_python/pyrelation.hpp index e1f78b5a..e272ca41 100644 --- a/src/duckdb_py/include/duckdb_python/pyrelation.hpp +++ b/src/duckdb_py/include/duckdb_python/pyrelation.hpp @@ -235,7 +235,7 @@ struct DuckDBPyRelation { void InsertInto(const string &table); - void Insert(const py::object ¶ms = py::list()); + void Insert(const py::object ¶ms = py::list()) const; void Update(const py::object &set, const py::object &where = py::none()); void Create(const string &table); diff --git a/src/duckdb_py/pyrelation.cpp b/src/duckdb_py/pyrelation.cpp index 3553bff0..08b001be 100644 --- a/src/duckdb_py/pyrelation.cpp +++ b/src/duckdb_py/pyrelation.cpp @@ -1511,14 +1511,10 @@ DuckDBPyRelation &DuckDBPyRelation::Execute() { void DuckDBPyRelation::InsertInto(const string &table) { AssertRelation(); auto parsed_info = QualifiedName::Parse(table); - auto insert = rel->InsertRel(parsed_info.schema, parsed_info.name); + auto insert = rel->InsertRel(parsed_info.catalog, parsed_info.schema, parsed_info.name); PyExecuteRelation(insert); } -static bool IsAcceptedInsertRelationType(const Relation &relation) { - return relation.type == RelationType::TABLE_RELATION; -} - void DuckDBPyRelation::Update(const py::object &set_p, const py::object &where) { AssertRelation(); unique_ptr condition; @@ -1563,9 +1559,9 @@ void DuckDBPyRelation::Update(const py::object &set_p, const py::object &where) return rel->Update(std::move(names), std::move(expressions), std::move(condition)); } -void DuckDBPyRelation::Insert(const py::object ¶ms) { +void DuckDBPyRelation::Insert(const py::object ¶ms) const { AssertRelation(); - if (!IsAcceptedInsertRelationType(*this->rel)) { + if (this->rel->type != RelationType::TABLE_RELATION) { throw InvalidInputException("'DuckDBPyRelation.insert' can only be used on a table relation"); } vector> values {DuckDBPyConnection::TransformPythonParamList(params)}; diff --git a/tests/fast/test_insert.py b/tests/fast/test_insert.py index a61efd2e..455e6e48 100644 --- a/tests/fast/test_insert.py +++ b/tests/fast/test_insert.py @@ -27,6 +27,4 @@ def test_insert_with_schema(self, duckdb_cursor): res = duckdb_cursor.table("not_main.tbl").fetchall() assert len(res) == 10 - # TODO: This is not currently supported # noqa: TD002, TD003 - with pytest.raises(duckdb.CatalogException, match="Table with name tbl does not exist"): - duckdb_cursor.table("not_main.tbl").insert([42, 21, 1337]) + duckdb_cursor.table("not_main.tbl").insert((42,))