mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-23 17:08:34 +00:00
Improvement - handle resolved data structures from pyproxies (#5904)
* handle resolved data structures from pyproxies * removes console.log
This commit is contained in:
parent
542aa5b278
commit
9ad8b72b83
1 changed files with 15 additions and 1 deletions
|
|
@ -152,7 +152,7 @@ async function executeRunPycode(_ref, code, query, editorState, isPreview, mode)
|
|||
};
|
||||
}
|
||||
|
||||
return pyodide.isPyProxy(result) ? result.toJs() : result;
|
||||
return pyodide.isPyProxy(result) ? convertMapSet(result.toJs()) : result;
|
||||
};
|
||||
|
||||
return { data: await evaluatePythonCode(pyodide, code) };
|
||||
|
|
@ -1592,3 +1592,17 @@ const getSelectedText = () => {
|
|||
navigator.clipboard.writeText(window.document.selection.createRange().text);
|
||||
}
|
||||
};
|
||||
|
||||
function convertMapSet(obj) {
|
||||
if (obj instanceof Map) {
|
||||
return Object.fromEntries(Array.from(obj, ([key, value]) => [key, convertMapSet(value)]));
|
||||
} else if (obj instanceof Set) {
|
||||
return Array.from(obj).map(convertMapSet);
|
||||
} else if (Array.isArray(obj)) {
|
||||
return obj.map(convertMapSet);
|
||||
} else if (obj !== null && typeof obj === 'object') {
|
||||
return Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, convertMapSet(value)]));
|
||||
} else {
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue