OSGeo / gdal

GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.
https://gdal.org
Other
4.65k stars 2.46k forks source link

GDALGetOutputDriversForDatasetName: Handle driver name prefixes #10263

Open dbaston opened 2 weeks ago

dbaston commented 2 weeks ago

Feature description

I would have expected the following to either fail or create a table in the default Postgres database:

ogr2ogr PG av_lv95.gpkg resf

Instead, it creates a directory called PG and a shapefile within that directory. To get the desired behavior I had to do

ogr2ogr "PG:" av_lv95.gpkg resf

I'm not sure what the best behavior is, but I think the first command I tried should either fail, warn on ambiguity, or magically do what I wanted :)

Additional context

No response

rouault commented 2 weeks ago

but I think the first command I tried should either fail, warn on ambiguity, or magically do what I wanted :)

I agree that might be surprising, but that's the 'expected' behavior. "PG" is not the recognized prefix of the PostgreSQL driver. It is "PG:". If we'd want to change that, then we shouldn't automatically select shapefile when there's no .dbf/.shp extension in the filename, which might be slightly breaking change