Skip to content

Commit

Permalink
Merge pull request #187 from mattdiez-at/add_sorted_env
Browse files Browse the repository at this point in the history
Added in environment variable for sorting/config
  • Loading branch information
vincentsarago authored Aug 30, 2024
2 parents c9e140f + 6b7ebcc commit 4654a91
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/src/user_guide/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion tipg/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tipg/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_",
Expand Down

0 comments on commit 4654a91

Please sign in to comment.