Skip to content

Commit 4654a91

Browse files
Merge pull request #187 from mattdiez-at/add_sorted_env
Added in environment variable for sorting/config
2 parents c9e140f + 6b7ebcc commit 4654a91

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

CHANGES.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
66

77
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`
88

9+
## Unreleased
10+
11+
* add `TIPG_SORT_COLUMNS` settings to enable/disable columns sorting (default to `True`) (author @mattdiez-at, https://github.com/developmentseed/tipg/pull/187)
12+
913
## [0.7.2] - 2024-08-27
1014

1115
* 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
310314
- Initial release
311315

312316
[unreleased]: https://github.com/developmentseed/tipg/compare/0.7.2...HEAD
313-
[0.7.1]: https://github.com/developmentseed/tipg/compare/0.7.1...0.7.2
317+
[0.7.2]: https://github.com/developmentseed/tipg/compare/0.7.1...0.7.2
314318
[0.7.1]: https://github.com/developmentseed/tipg/compare/0.7.0...0.7.1
315319
[0.7.0]: https://github.com/developmentseed/tipg/compare/0.6.3...0.7.0
316320
[0.6.3]: https://github.com/developmentseed/tipg/compare/0.6.2...0.6.3

docs/src/user_guide/configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ prefix: **`TIPG_`**
7979

8080
- **DATETIME_EXTENT** (bool): Fetch datetime extent by going throught all rows. Default is `True`
8181
- **FALLBACK_KEY_NAMES** (list of string): Primary Key names to look for in the tables. Default is `["ogc_fid", "id", "pkey", "gid"]`
82+
- **SORT_COLUMNS** (bool): Sort the `columns` for a table alphabetically. Default is `True`.
8283
- **TABLE_CONFIG** (dict of `TableConfig`)
8384
- **TABLE_CONFIG_ _ {schemaId}_{tableId} _ _GEOMCOL** (str): Table's geometry/geography column name
8485
- **TABLE_CONFIG_ _ {schemaId}_{tableId} _ _DATETIMECOL** (str): Table's datetime column name

tipg/collections.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,10 @@ async def get_collection_index( # noqa: C901
951951
table_conf = table_confs.get(confid, TableConfig())
952952

953953
# Make sure that any properties set in conf exist in table
954-
columns = sorted(table.get("properties", []), key=lambda d: d["name"])
954+
columns = table.get("properties", [])
955+
if table_settings.sort_columns:
956+
columns = sorted(columns, key=lambda d: d["name"])
957+
955958
properties_setting = table_conf.properties or [c["name"] for c in columns]
956959

957960
# ID Column

tipg/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class TableSettings(BaseSettings):
6262

6363
fallback_key_names: List[str] = ["ogc_fid", "id", "pkey", "gid"]
6464
table_config: Dict[str, TableConfig] = {}
65+
sort_columns: bool = True
6566

6667
model_config = {
6768
"env_prefix": "TIPG_",

0 commit comments

Comments
 (0)