Skip to content

feat(serverdb): Allow to redirect attributes via alias - #472

Open
kofrezo wants to merge 4 commits into
mainfrom
dk_attribute_redirects
Open

kofrezo wants to merge 4 commits into
mainfrom
dk_attribute_redirects

Conversation

@kofrezo

@kofrezo kofrezo commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

To ease renaming attributes this feature allows to set up an alias for an attribute so that requests still using the old name continue working and allow a graceful migration.

Do not resolve redirect in the Servershell as humans should pick up the new name immediately otherwise it could increase the risk to become a permanent thing because we humans are lazy

To ease renaming attributes this feature allows to set up an alias for
an attribute so that requests still using the old name continue working
and allow a graceful migration.

Do not resolve redirect in the Servershell as humans should pick up the
new name immediately otherwise it could increase the risk to become a
permanent thing because we humans are lazy
@kofrezo
kofrezo requested a review from Phantuman September 25, 2026 14:53
@kofrezo kofrezo self-assigned this Sep 25, 2026
@kofrezo
kofrezo requested a review from brainexe September 28, 2026 07:45
Comment thread packages/serveradmin/serveradmin/serverdb/admin.py Outdated
@brainexe

Copy link
Copy Markdown
Member

One issue while testing: related fields, like adminapi "project=admin" -a project.short_code' fails now, even without any alias:

web-1  | TypeError: unhashable type: 'dict'
web-1  | Internal Server Error: /api/dataset/query
web-1  |   File "/code/packages/serveradmin/serveradmin/api/views.py", line 72, in dataset_query
web-1  |     filters, restrict, order_by = AttributeRedirect.resolve_aliases(filters, restrict, order_by)
web-1  |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Forgot about the joined queries. Added a test with Claude
@kofrezo
kofrezo marked this pull request as draft September 28, 2026 14:12
@kofrezo

kofrezo commented Sep 28, 2026

Copy link
Copy Markdown
Contributor Author

Darn I found more. It currently does not work for the restricting attributes because the aliases are resolved and then the result is returned with the real attribute names and the values for the alias are missing on client side:

# E.g. operating_system -> os
uv run adminapi "operating_system=bullseye" -a operating_system                                                                                       
{N/A}
{N/A}
{N/A}

When querying objects and accessing them by the alias we must ensure the
results are present via the alias attribute again.
@kofrezo
kofrezo marked this pull request as ready for review September 29, 2026 14:03
@kofrezo
kofrezo requested a review from brainexe September 29, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants