-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor
sort_keys
implementation (#970)
Fixes #956 While ideally we set the sort_keys on the Schema of a TableModel, or on the TableModel themselves, this is not directly possible AFAIK: - Schemas are autogenerated, and sort_keys is not something we can serialize or parse in a JSONSchema - The TableModels are generic (TableModel[T]), so specific sort_keys can't be hardcoded to a class. The previous approach was to hold the sort keys in a `Dict[table, sort_keys]` on a NodeModel (which holds multiple tables), and passing them on when save/sort was called from the Node. This PR improves on that approach by introducing a private _sort_keys on the TableModel, which is always set (from an empty list by default) on initialization from the NodeModel. Instead of keeping a separate Dict with sort_keys on a NodeModel, we now set them in the `Field` attribute `json_schema_extra` (the only customizable attribute of a Field) for each field. Each field of a NodeModel is now validated by default (also on assignment), and if a sort_keys is present for a fieldtype, it is set on the TableModel. Based on the initial exploration by @deltamarnix in https://github.com/Deltares/Ribasim/tree/feat/sort-keys-in-tablemodel
- Loading branch information
Showing
3 changed files
with
79 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters