Skip to content

Commit e5149df

Browse files
committed
Try to fill the blank using the diff file instead of only the base file
1 parent 036d0c3 commit e5149df

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

Mergin/diff.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@ def diff_table_to_features(diff_table, schema_table, fields, cols_to_flds, db_co
214214

215215
f["_op"] = entry_type
216216

217-
# try to fill in unchanged columns from the database
218217
if entry_type == "update" and db_conn is not None:
218+
# try to fill in unchanged columns from the database
219219
db_row = get_row_from_db(db_conn, schema_table, entry_changes)
220220

221221
for i in range(len(db_row)):
@@ -233,6 +233,22 @@ def diff_table_to_features(diff_table, schema_table, fields, cols_to_flds, db_co
233233
else:
234234
f[cols_to_flds[i]] = db_row[i]
235235
f[cols_to_flds[i] + fld_old_offset] = db_row[i]
236+
237+
# try to fill in unchanged columns from the diff
238+
for entry_change in entry_changes:
239+
i = entry_change["column"]
240+
if "old" in entry_change:
241+
if i == geom_col_index:
242+
if entry_change["old"] == None:
243+
# Empty geometry
244+
continue
245+
wkb_with_gpkg_hdr = base64.decodebytes(entry_change["old"].encode("ascii"))
246+
wkb = parse_gpkg_geom_encoding(wkb_with_gpkg_hdr)
247+
g = QgsGeometry()
248+
g.fromWkb(wkb)
249+
f.setGeometry(g)
250+
else:
251+
f[cols_to_flds[i] + fld_old_offset] = entry_change["old"]
236252

237253
for entry_change in entry_changes:
238254
i = entry_change["column"]

0 commit comments

Comments
 (0)