Skip to content

Commit abf9ec6

Browse files
authored
refactor: simplify redundant expressions in display and workspace_selector (#11)
* feat: add database= parameter to sql engine and editor for managed database scoping Pass database= to client.execute_sql() so queries are scoped to a managed database via the X-Database-Id header (hotdata-runtime>=0.2.1). - HotdataMarimoEngine: add default_database= constructor param, pass to execute() - SqlEditor: add database= constructor param, pass to both execute_sql calls - ManagedDatabaseWriter: use description= kwarg matching ManagedDatabase v0.2.0 API - Fix test_databases_marimo.py syntax error and update assertions * refactor: eliminate flag-based side-effect tracking, fix unregister, remove dead code - table_browser: extract _set_table_pick() replacing duplicate _init/_rebuild methods; _sync_table_catalog returns bool so ui drops _rebuilt_table_pick_this_run flag; standardize _active_connection_id to use 'or None' consistently - sql_engine: unregister now restores original engine_to_data_source_connection and resets sentinel so register/unregister/register round-trip works correctly - sql_editor: remove dead 'or ""' on _cached_sql (already guarded by None check above) - workspace_selector: cache HotdataClient, only reconstruct when workspace_id changes * fix: pass dropdown label key (not value) to mo.ui.dropdown value= init param When options is a dict {label: value}, Marimo validates value= against the dict keys (labels), not the values. _rebuild_database_pick was passing a database ID (dict value) which raised ValueError on startup. Now resolves the label key corresponding to the previously-selected ID instead. * docs: rewrite README with quickstart and usage examples * chore: remove publish-workflow.sh scaffold (workflow already generated) * refactor: simplify redundant expressions in display and workspace_selector --------- Co-authored-by: Eddie A Tejeda <669988+eddietejeda@users.noreply.github.com>
1 parent 0c40968 commit abf9ec6

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

hotdata_marimo/display.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,13 @@ def selected_result_id(self) -> str | None:
9090
row = selected[0]
9191
if not isinstance(row, dict):
9292
return None
93-
rid = row.get("result_id")
94-
return rid if rid else None
93+
return row.get("result_id") or None
9594

9695
@property
9796
def result(self) -> QueryResult:
9897
rid = self.selected_result_id
9998
mo.stop(rid is None, mo.md("Select a result row to load."))
100-
return self._client.get_result(rid or "")
99+
return self._client.get_result(rid)
101100

102101
@property
103102
def result_panel(self):

hotdata_marimo/workspace_selector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def workspace_id(self) -> str:
6262
if self._pick is None:
6363
return self._workspace_id
6464
v = self._pick.value
65-
return v if v else self._workspace_id
65+
return v or self._workspace_id
6666

6767
@property
6868
def client(self) -> HotdataClient:

0 commit comments

Comments
 (0)