Skip to content
Merged
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
27 changes: 23 additions & 4 deletions src/dbzero/bindings/python/Memo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,10 +685,29 @@ namespace db0::python

PyObject *tryGetAttributes(PyTypeObject *type)
{
auto &decor = MemoTypeDecoration::get(type);
auto fixture = PyToolkit::getPyWorkspace().getWorkspace().getFixture(decor.getFixtureUUID(), AccessType::READ_ONLY);
auto &class_factory = fixture->get<db0::object_model::ClassFactory>();
return tryGetClassAttributes(*class_factory.getExistingType(type));
auto &decor = MemoTypeDecoration::get(type);
auto &workspace = PyToolkit::getPyWorkspace().getWorkspace();
auto fixture = workspace.getFixture(decor.getFixtureUUID(), AccessType::READ_ONLY);
auto &class_factory = fixture->get<db0::object_model::ClassFactory>();
// for scoped types, we raise an error if class not found
if (decor.isScoped()) {
return tryGetClassAttributes(*class_factory.getExistingType(type));
} else {
// otherwise we check the default prefix and also scan other open prefixes
// in search for the class
auto type_ptr = class_factory.tryGetExistingType(type);
workspace.forEachFixture([&](const Fixture &existing_fixture) {
if (!type_ptr && existing_fixture != *fixture) {
auto &class_factory = existing_fixture.get<db0::object_model::ClassFactory>();
type_ptr = class_factory.tryGetExistingType(type);
}
return !type_ptr;
});
if (!type_ptr) {
THROWF(db0::InputException) << "Class not found: " << PyToolkit::getTypeName(type);
}
return tryGetClassAttributes(*type_ptr);
}
}

PyObject *tryGetAttrAs(MemoObject *memo_obj, PyObject *attr, PyTypeObject *py_type)
Expand Down
2 changes: 1 addition & 1 deletion src/dbzero/bindings/python/MemoTypeDecoration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ namespace db0::python
return m_type_id;
}

// Check if scoped of this type is limited to a specific prefix
// Check if scope of this type is limited to a specific prefix
bool isScoped() const;

// NOTE: may return invalid / empty prefix name
Expand Down
2 changes: 1 addition & 1 deletion src/dbzero/object_model/class/Class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ namespace db0::object_model

std::optional<std::string> getNameVariant(std::optional<std::string> type_id, std::optional<std::string> type_name,
std::optional<std::string> module_name, std::optional<std::string> type_fields_str, int variant_id)
{
{
switch (variant_id) {
case 0: {
if (!type_id) {
Expand Down