geocloud2
geocloud2 copied to clipboard
Error on empty sort_id
Failures observed:
- Unable to create mapfile
- Unable to view data in GC2 admin
- Unable to generate metadata
Each of the services til return an error like:
{"success":false,"message":"Unsupported operand types: int - string","code":500}
The cause of this is an empty value in the fieldconf of a featuretype. if the value of "sort_id" is "" (empty string) PHP will fail.
I've used this to find the relevant information in settings.geometry_columns_join
:
SELECT
_key_,
key AS json_key,
value->>'sort_id' AS sort_id
FROM settings.geometry_columns_view, jsonb_each(fieldconf::jsonb)
WHERE value->>'sort_id' IS NULL OR value->>'sort_id' = ''
if your table is very old, fieldconf
might not be valid json and the statement will throw errors.
i suggest a check for null/empty values and default to 0 when getting the information.