Overcome issues with importing Column Names which are Reserved words

Both MapServer and PostgreSQL have Reserved words / Keywords which, if used as column names, will cause issues when trying to display the data in iShare.

Scenario 1 - Invalid ID column

Here is an example where the column name Id has been used. The data being displayed should read Eastney or Milton but instead has the same numerical value.

The way to solve this is to amend the DATA entry in the .MAP file for the LAYER to rename the field.

Before renaming
DATA "wkb_geometry from (select * from gis.neighbourhoodforums) as foo using unique ogc_fid using SRID=27700"
Renaming 'id' column as 'ident'
DATA "wkb_geometry from (select *, id AS ident from gis.neighbourhoodforums) as foo using unique ogc_fid using SRID=27700"

Scenario 2 - Invalid Legend column

Here is another example where the column name of legend has been used - this is a MapServer reserved word. Here it is displaying the name of the legend image instead of the data.

In this instance the MapServer column Type was created from the PostgreSQL legend field within Studio as per the screenshot below:

Here you would change the .MAP file as follows:

DATA "wkb_geometry from (select *, legend AS landtype  from gis.highwaysadopted_base) as foo using unique ogc_fid using SRID=27700"