feat: add label parameter to add_column and modify_column tools

Allow setting a human-readable display label for columns, separate from
the column_id used in formulas and API calls. The label defaults to the
column_id if not provided.
This commit is contained in:
2026-01-26 15:18:11 -05:00
parent d4e793224b
commit 33bb464102
5 changed files with 94 additions and 5 deletions

View File

@@ -203,11 +203,14 @@ class GristClient:
column_id: str,
column_type: str,
formula: str | None = None,
label: str | None = None,
) -> str:
"""Add a column to a table. Returns column ID."""
fields = {"type": column_type}
if formula:
fields["formula"] = formula
if label:
fields["label"] = label
payload = {"columns": [{"id": column_id, "fields": fields}]}
data = await self._request("POST", f"/tables/{table}/columns", json=payload)
@@ -219,13 +222,16 @@ class GristClient:
column_id: str,
type: str | None = None,
formula: str | None = None,
label: str | None = None,
) -> None:
"""Modify a column's type or formula."""
"""Modify a column's type, formula, or label."""
fields = {}
if type is not None:
fields["type"] = type
if formula is not None:
fields["formula"] = formula
if label is not None:
fields["label"] = label
payload = {"columns": [{"id": column_id, "fields": fields}]}
await self._request("PATCH", f"/tables/{table}/columns", json=payload)