diff --git a/CHANGES.md b/CHANGES.md index f232fae..4fe0aef 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/). Note: Minor version `0.X.0` update might break the API, It's recommended to pin `tipg` to minor version: `tipg>=0.1,<0.2` +## Unreleased + +* add `TIPG_SORT_COLUMNS` settings to enable/disable columns sorting (default to `True`) (author @mattdiez-at, https://github.com/developmentseed/tipg/pull/187) + ## [0.7.2] - 2024-08-27 * move back to `fastapi` dependency @@ -310,7 +314,7 @@ Note: Minor version `0.X.0` update might break the API, It's recommended to pin - Initial release [unreleased]: https://github.com/developmentseed/tipg/compare/0.7.2...HEAD -[0.7.1]: https://github.com/developmentseed/tipg/compare/0.7.1...0.7.2 +[0.7.2]: https://github.com/developmentseed/tipg/compare/0.7.1...0.7.2 [0.7.1]: https://github.com/developmentseed/tipg/compare/0.7.0...0.7.1 [0.7.0]: https://github.com/developmentseed/tipg/compare/0.6.3...0.7.0 [0.6.3]: https://github.com/developmentseed/tipg/compare/0.6.2...0.6.3 diff --git a/docs/src/user_guide/configuration.md b/docs/src/user_guide/configuration.md index 6290966..fa43ce6 100644 --- a/docs/src/user_guide/configuration.md +++ b/docs/src/user_guide/configuration.md @@ -79,6 +79,7 @@ prefix: **`TIPG_`** - **DATETIME_EXTENT** (bool): Fetch datetime extent by going throught all rows. Default is `True` - **FALLBACK_KEY_NAMES** (list of string): Primary Key names to look for in the tables. Default is `["ogc_fid", "id", "pkey", "gid"]` +- **SORT_COLUMNS** (bool): Sort the `columns` for a table alphabetically. Default is `True`. - **TABLE_CONFIG** (dict of `TableConfig`) - **TABLE_CONFIG_ _ {schemaId}_{tableId} _ _GEOMCOL** (str): Table's geometry/geography column name - **TABLE_CONFIG_ _ {schemaId}_{tableId} _ _DATETIMECOL** (str): Table's datetime column name diff --git a/tipg/collections.py b/tipg/collections.py index d50afa4..b003f77 100644 --- a/tipg/collections.py +++ b/tipg/collections.py @@ -951,7 +951,10 @@ 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"]) + columns = table.get("properties", []) + if table_settings.sort_columns: + columns = sorted(columns, key=lambda d: d["name"]) + 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..f57855b 100644 --- a/tipg/settings.py +++ b/tipg/settings.py @@ -62,6 +62,7 @@ class TableSettings(BaseSettings): fallback_key_names: List[str] = ["ogc_fid", "id", "pkey", "gid"] table_config: Dict[str, TableConfig] = {} + sort_columns: bool = True model_config = { "env_prefix": "TIPG_",