Skip to content

Commit

Permalink
Merge pull request #10664 from OSGeo/backport-10662-to-release/3.9
Browse files Browse the repository at this point in the history
[Backport release/3.9] OpenFileGDB writer: fix writing a Int32 field with value -21121
  • Loading branch information
rouault authored Aug 28, 2024
2 parents 4a95929 + 66d688f commit 334cc61
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions autotest/ogr/ogr_openfilegdb_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -4565,3 +4565,22 @@ def test_ogr_openfilegdb_repair_corrupted_header(tmp_vsimem):
ds = ogr.Open(filename)
assert gdal.GetLastErrorMsg() == ""
assert ds.GetLayerCount() == 1


###############################################################################
# Test writing special value OGRUnsetMarker = -21121 in a int32 field


def test_ogr_openfilegdb_write_OGRUnsetMarker(tmp_vsimem):

filename = str(tmp_vsimem / "out.gdb")
with ogr.GetDriverByName("OpenFileGDB").CreateDataSource(filename) as ds:
lyr = ds.CreateLayer("test", geom_type=ogr.wkbNone)
lyr.CreateField(ogr.FieldDefn("i32", ogr.OFTInteger))
f = ogr.Feature(lyr.GetLayerDefn())
f["i32"] = -21121
lyr.CreateFeature(f)
with ogr.Open(filename) as ds:
lyr = ds.GetLayer(0)
f = lyr.GetNextFeature()
assert f["i32"] == -21121
1 change: 1 addition & 0 deletions ogr/ogrsf_frmts/openfilegdb/ogropenfilegdblayer_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2263,6 +2263,7 @@ bool OGROpenFileGDBLayer::PrepareFileGDBFeature(OGRFeature *poFeature,
}
continue;
}
memset(&fields[idxFileGDB], 0, sizeof(OGRField));
switch (m_poLyrTable->GetField(idxFileGDB)->GetType())
{
case FGFT_UNDEFINED:
Expand Down

0 comments on commit 334cc61

Please sign in to comment.