Skip to content

Commit 0a23723

Browse files
committed
nanobind: enum-instance acceptance in STRING_INT caster; .none() on join other_rel
1 parent 1b115b6 commit 0a23723

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/duckdb_py/include/duckdb_python/pybind11/conversions/enum_string_caster.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@
4040
value = FromIntegerFn(nanobind::cast<int64_t>(src)); \
4141
return true; \
4242
} \
43+
/* Registered nb::enum_ instances aren't int subclasses (unlike pybind11's), so accept a member */ \
44+
/* of the registered enum by reading its integer .value. */ \
45+
nanobind::handle enum_type = nanobind::type<EnumType>(); \
46+
if (enum_type.is_valid() && PyObject_IsInstance(src.ptr(), enum_type.ptr()) == 1) { \
47+
value = FromIntegerFn(nanobind::cast<int64_t>(src.attr("value"))); \
48+
return true; \
49+
} \
4350
} catch (...) { \
4451
return false; \
4552
} \

src/duckdb_py/pyrelation/initialize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ void DuckDBPyRelation::Initialize(py::handle &m) {
325325
.def("join", &DuckDBPyRelation::Join,
326326
"Join the relation object with another relation object in other_rel using the join condition expression "
327327
"in join_condition. Types supported are 'inner', 'left', 'right', 'outer', 'semi' and 'anti'",
328-
py::arg("other_rel"), py::arg("condition"), py::arg("how") = "inner")
328+
py::arg("other_rel").none(), py::arg("condition"), py::arg("how") = "inner")
329329
.def("cross", &DuckDBPyRelation::Cross, "Create cross/cartesian product of two relational objects",
330330
py::arg("other_rel"))
331331

0 commit comments

Comments
 (0)