[postgis-tickets] [PostGIS] #4705: pgsql2shp - Pg field column in mapping file incorrectly compared with the name of the dbf field name

PostGIS trac at osgeo.org
Sun Jun 21 04:00:41 PDT 2020


#4705: pgsql2shp - Pg field column in mapping file incorrectly compared with the
name of the dbf field name
----------------------------+-------------------
  Reporter:  zezzagio       |      Owner:  robe
      Type:  defect         |     Status:  new
  Priority:  medium         |  Milestone:
 Component:  loader/dumper  |    Version:  3.0.x
Resolution:                 |   Keywords:
----------------------------+-------------------

Comment (by zezzagio):

 Replying to [comment:19 strk]:

 > Git work is great, but someone will need to double check

 Of course someone will need to double check! it's the because I don't
 understand.

 > Git work is great, but someone will need to double check this because
 > the header file also says that function wants the PG name, not the DBF
 > name:
 >
 >   const char *colmap_dbf_by_pg(colmap *map, const char *pgname);
 >   const char *colmap_pg_by_dbf(colmap *map, const char *dbfname);

 Exactly so! the header says it wants the PG name, the code called it with
 the DBF name.

 > Those signatures are in loader/shpcommon.h, lacking a comment.
 >
 > The help output from shp2pgsql says the format is:
 >
 >          COLUMNNAME DBFFIELD1
 >          AVERYLONGCOLUMNNAME DBFFIELD2
 >
 > So we have the PostgreSQL column name on the left and the
 > DBF field name on the right.
 >
 > The _same_ format is expected by pgsql2shp
 > (yes, key on the right in this case).

 No, the "key" (i.e. the searched value) is on the left for pgsql2shp. We
 are searching for a PG column, in order to get the corresponding DBF
 column.

 The functions colmap_dbf_by_pg and colmap_pg_by_dbf are quite similar (and
 quite simple): they compare an array of strings (map) against a value
 (key).

 In the case of colmap_dbf_by_pg, the array of PG fields names is compared
 against the PG field name (returning the corresponding DBF field name); in
 the case of colmap_pg_by_dbf the array of DBF fields names is compared
 against the DBF field name (returning the correponding PG field name.)

 The mapping file is the same; this seems a good choice to me.

 > You are changing this:
 >
 > - const char *mapped = colmap_dbf_by_pg(&state->column_map,
 dbffieldname);
 > + const char *mapped = colmap_dbf_by_pg(&state->column_map,
 pgfieldname);
 >
 > Does not seem to match with parameter names in signature...

 I don't understand. It ''didn't'' match, in fact; now it does.

-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/4705#comment:21>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-tickets mailing list