Ticket #4458 (closed defect: fixed)

Opened 16 months ago

Last modified 16 months ago

[PATCH] FGDB driver does not ensure feature class names are valid

Reported by: ryanl Owned by: warmerdam
Priority: normal Milestone: 1.9.1
Component: OGR_SF Version: 1.9.0
Severity: normal Keywords: FileGDB, File Geodatabase
Cc: robert.coup@…

Description

If an input contains field names that are invalid in a FGDB the driver attempts to add them directly, error messages are displayed and the resulting database does not contain the fields.

ERROR 1: Error: Failed at creating Field for 9NUMBER (The name of the Field is invalid: valid names may contain letters, numbers or underscores.)
Warning 1: The output driver has claimed to have added the 9NUMBER field, but it did not!

The FGDB API also lets you create fields with reserved words but these will break when opened with ArcMap?, this will be fixed with the next API release apparently.

The attached patch cleans field names by changing invalid characters to "_", appending "_" to reserved words (similarly to ArcCatalog?), shrinks names to 64 characters and ensures uniqueness of the names. It also adds an alias to the original field name.

I have attached an example csv that contains several fields with invalid names and the expected output.

References:

Attachments

cleanFields.diff Download (5.7 KB) - added by ryanl 16 months ago.
fix against r23761
tests.csv Download (0.6 KB) - added by ryanl 16 months ago.
Data I used to check patch
tests.vrt Download (287 bytes) - added by ryanl 16 months ago.
Data I used to check patch
cleanFields.2.diff Download (5.8 KB) - added by ryanl 16 months ago.
Patch using jpalmer's idea to prefix fields starting with a number
keyword_case.patch Download (0.9 KB) - added by jpalmer 16 months ago.
The current implementation does not do a case insensitive match. This patch fixes this.

Change History

Changed 16 months ago by ryanl

fix against r23761

Changed 16 months ago by ryanl

Data I used to check patch

Changed 16 months ago by ryanl

Data I used to check patch

Changed 16 months ago by jpalmer

Hi Ryan,

I would modify the patch to ensure that fields that start with a number get an underscore prefixed to the field name, rather than replacing the number character with an underscore. i.e "9NUMBER" becomes "_9NUMBER" rather than "_NUMBER". This way fields names have a better chance of remaining unique and the process won't error.

Cheers Jeremy

Changed 16 months ago by ryanl

Patch using jpalmer's idea to prefix fields starting with a number

Changed 16 months ago by rouault

  • status changed from new to closed
  • version changed from svn-trunk to 1.9.0
  • resolution set to fixed
  • milestone set to 1.9.1

r23777 /trunk/ (6 files in 2 dirs): FileGDB: do compulsory field name laundering. Add a LAUNDER_RESERVED_KEYWORDS layer creation option, which defaults to YES, to control whether an optional laundering step should also be done (adapted from a patch by ryanl, #4458)

r23778 /branches/1.9/gdal/ogr/ogrsf_frmts/filegdb/ (5 files): FileGDB: do compulsory field name laundering. Add a LAUNDER_RESERVED_KEYWORDS layer creation option, which defaults to YES, to control whether an optional laundering step should also be done (adapted from a patch by ryanl, #4458)

Changed 16 months ago by rouault

r23787 /trunk/gdal/ogr/ogrsf_frmts/filegdb/drv_filegdb.html: FileGDB: un-document LAUNDER_RESERVED_KEYWORDS option. Setting it to NO isn't really usefull (#4458)

r23788 /branches/1.9/gdal/ogr/ogrsf_frmts/filegdb/drv_filegdb.html: FileGDB: un-document LAUNDER_RESERVED_KEYWORDS option. Setting it to NO isn't really usefull (#4458)

Changed 16 months ago by jpalmer

The current implementation does not do a case insensitive match. This patch fixes this.

Changed 16 months ago by jpalmer

  • status changed from closed to reopened
  • resolution fixed deleted

Changed 16 months ago by rouault

  • status changed from reopened to closed
  • resolution set to fixed

Applied in trunk (r23858) and branches/1.9 (r23859)

Note: See TracTickets for help on using tickets.