diff --git a/docs/src/user_guide/configuration.md b/docs/src/user_guide/configuration.md index 6290966..e4bf326 100644 --- a/docs/src/user_guide/configuration.md +++ b/docs/src/user_guide/configuration.md @@ -129,6 +129,7 @@ prefix: **`TIPG_`** - **DEFAULT_FEATURES_LIMIT** (int): Set the default `Limit` values for `/items` endpoint. Default is `10` - **MAX_FEATURES_PER_QUERY** (int): Set the maximum number of features the `/items` endpoint can return. Default is `10000`. +- **SORT_COLUMNS** (bool): Sort the `columns` for a feature alphabetically. Default is `True`. ```bash TIPG_DEFAULT_FEATURES_LIMIT=1000 TIPG_MAX_FEATURES_PER_QUERY=2000 diff --git a/tipg/collections.py b/tipg/collections.py index d50afa4..09e313e 100644 --- a/tipg/collections.py +++ b/tipg/collections.py @@ -951,7 +951,11 @@ async def get_collection_index( # noqa: C901 table_conf = table_confs.get(confid, TableConfig()) # Make sure that any properties set in conf exist in table - columns = sorted(table.get("properties", []), key=lambda d: d["name"]) + if features_settings.sort_columns: + columns = sorted(table.get("properties", []), key=lambda d: d["name"]) + else: + columns = table.get("properties", []) + properties_setting = table_conf.properties or [c["name"] for c in columns] # ID Column diff --git a/tipg/settings.py b/tipg/settings.py index b050136..20058ac 100644 --- a/tipg/settings.py +++ b/tipg/settings.py @@ -86,6 +86,7 @@ class FeaturesSettings(BaseSettings): default_features_limit: int = Field(10, ge=0) max_features_per_query: int = Field(10000, ge=0) + sort_columns: bool = True model_config = {"env_prefix": "TIPG_", "env_file": ".env", "extra": "ignore"}