Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport release/3.9] OpenFileGDB writer: fix writing a Int32 field with value -21121 #10664

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading