Opened 15 years ago

Closed 15 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:

Description

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, 15 years ago

We do escape some already (oid included), it's just a matter of adding more. Ref: http://trac.osgeo.org/postgis/browser/trunk/loader/shp2pgsql-core.c#L1185

comment:2 by strk, 15 years ago

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

http://trac.osgeo.org/postgis/browser/trunk/loader/pgsql2shp.c#L1586

comment:3 by springmeyer, 15 years ago

+1!

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, 15 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.