I have a table that consists of some PostGIS related data. These data are generated automatically on INSERT or UPDATE.
ALTER TABLE "Room" ADD COLUMN geolocation geography(Polygon, 4326) GENERATED ALWAYS AS (ST_MakePolygon("polygon"::geometry)) STORED;
Sometimes the data provided on the polygon column might not fit the generation function and cause an error. I wanted to handle this error and set a default value when it fail.
-- Last resort options --
- Creating postgres functions that handle this task but that would disassociate the work from the codebase.