gdal
gdal copied to clipboard
Postgres: Impossible to specify COLUMN_TYPES for fields which contain certain characters
The pg
driver supports an open option COLUMN_TYPES
, which contains key-value pairs separated by commas allowing you to override Postgres field types.
However, due to the simplistic way this parameter is parsed, it seems to be impossible to override column types in certain situations:
- where you have more than one column whose names contain open parentheses
(
but no closing parenthesis)
, such asEasting (m
andArea (sqkm
(very plausible field names from a SHP or DBF) - where the field name contains an equal sign
=
or colon:
This may seem like an edge case, but we have run into this in our production systems. I've put a crude workaround in place but it really needs to be fixed in GDAL, and it's not clear what the best way to solve it is.
Maybe some backslash escaping logic? (assuming backslash are extremely unlikely to appear in column names)
Good idea. Something like:
\\ → \
\= → =
\: → :
Also we could restrict the special parsing of ( )
to after an =
or :
delimiter has been encountered, as it is not needed in the column name (key) portion of the input.
@atlight I let it to you?