gws.base.database.util

Database utilities.

Source code: gws.base.database.util

Module Contents

gws.base.database.util.shape_intersects_clause(column, shape: gws.Shape, crs: gws.Crs) → gws.lib.sa.ColumnElement

Create a where clause that matches geometries intersecting a shape.

Parameters:
  • column – Geometry column expression.

  • shape – Shape to intersect with.

  • crs – CRS of the column. The shape is transformed to it.

Returns:

An ST_Intersects clause.

gws.base.database.util.text_search_clause(column, value: str | None, tso: gws.TextSearchOptions | None) → gws.lib.sa.ColumnElement | None

Create a where clause that matches a column against a search string.

The value is stripped. For the any, begin and end search types, LIKE wildcards in the value match literally. For the like type, the value is used as a LIKE pattern, with \ as the escape character.

Parameters:
  • column – Column expression to match.

  • value – Search string.

  • tso – Text search options. Without options, the value is matched exactly.

Returns:

A clause, or None if the value is empty or shorter than the minimum length.