Using GDAL's ogr2ogr to load data from a DBF I've downloaded from a proprietary system into PostgreSQL. The data has date fields where no-data records are stored as 0000/00/00
, so I'm using SQLite's NULLIF function to change these to proper NULL
values; if I left them, ogr2ogr was producing errors being unable to handle the date values. As a result of using SQLite though, I'm then facing the issue of SQLite not handling the Boolean fields properly. I know SQLite doesn't have a Boolean type, but I'm expecting it to just be treated as a standard integer in that case, however I'm unable to get it to keep the True
values as 1
, with everything instead just going to 0
(i.e. False
). I've tried experimenting forcing the casting via -sql "SELECT CAST(field AS Integer) FROM table"
and also -mapFieldType Integer(Boolean)=Integer
.
I've tried doing ogrinfo and also doing ogr2ogr into a different format, however it appears the issue is consistent once using a SQLite query. I have made a sample version of the dataset available at https://github.com/trodaway/filesharing/blob/main/example.dbf
Is there a way round this?
Note: I have been using GDAL 3.9.1, although the date issue should be resolved in the recently released 3.9.2, so I might be able to get around the boolean issue with this, however this doesn't fix the root cause issue if it does happen to be a bug.