Writing to GeoPackage doesn't check for SQL-protected words in column names or "forbidden" characters in layer names
See original GitHub issueExpected behavior and actual behavior.
When creating a GPKG
file, there are a few safe-checks that are missing. The two kinds of problems I’ve identified are:
- Column names that use SQL protected words, like
select
andcount
are currently allowed - Layer names that contain hyphens are allowed
Currently, Fiona
allows you to generate GeoPackage files that violate these rules. However, when you try to open files that violate these rules in ArcGIS Pro, the file fails to load and you just get a non-descriptive error message.
My expectation is that the columns should be automatically renamed to avoid clashes with SQL-protected words. Offending columns can have an underscore added to the end.
Furthermore, layer names should automatically transform hyphens into underscores.
Note: Since I mainly use Fiona
through GeoPandas
, I’ve also created an issue on their Github.
Note 2: Apologies for the example below using GeoPandas
Steps to reproduce the problem.
import geopandas as gpd
test_gdf = gpd.GeoDataFrame({'my_id':[1,2,3],
'select':[1,2,3],
'count':[1,2,3]},
geometry=gpd.points_from_xy([0,1,2], [0,1,2]),
crs='epsg:4326')
test_gdf.to_file('test.gpkg', driver='GPKG',layer='with-hyphen')
Then, try to open the with-hyphen
layer from the test.gpkg'
file in ArcGIS Pro. An error message will pop up.
Operating system
Windows 10
Fiona and GDAL version and provenance
fiona: 1.8.13.post1 (installed through Anaconda, I think) GDAL: 3.0.2 (installed through Anaconda
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top GitHub Comments
Understood. That makes sense to me. It felt like a stretch as a suggestion.
select * from "test-table"
seems also to work. Note that this is with PostGIS and not GPKG/SQLite.I don’t want to rule out that there are restrictions, I’m just at the moment not aware of any.