Opened 14 years ago

Closed 14 years ago

#504 closed enhancement (fixed)

shp2pgsql should rename xmin/xmax fields

Reported by: pramsey Owned by: pramsey
Priority: low Milestone: PostGIS 1.5.2
Component: postgis Version: 1.5.X
Keywords: Cc:


There are some column names that cannot be used (oid, xmin, etc) and shp2pgsql should rename input fields to avoid colliding with them automatically (prepend an _ for example).

Change History (4)

comment:1 by strk, 14 years ago

We do escape some already (oid included), it's just a matter of adding more. Ref:

comment:2 by strk, 14 years ago

And, for the record, the dumper recognizes the escape character (_) when recreating the shapefile:

comment:3 by springmeyer, 14 years ago


Exposing the ability to configure the escape character used would also be a valuable thing from my perspective. Not critical at all and potentially not useful to 99% of users, but the basic situation is that I frequently use shp2pgsql to load arbitrary shapefiles into postgis, and then dynamically build django models (in python) from the table schema created by shp2pgsql. A gocha is that the _ is illegal according to django for field names (not sure why), so I have to batch find and rename those fields to remove the leading _.

comment:4 by strk, 14 years ago

Resolution: fixed
Status: newclosed

xmin escaped as of r5566. xmax was already escaped.

The user-defined escape char might be useful but worth a separate ticket. Note that in order to be symmetric any user-defined escape should be also reflected in the dumper.

Note: See TracTickets for help on using tickets.