Skip to content

Commit 2867b08

Browse files
committed
Add os.environ flags for avoiding structural changes
1 parent ea6ec69 commit 2867b08

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

kart/tabular/working_copy/base.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,15 @@ def _do_reset_datasets(
12001200
# Check if the dataset is spatial, and if so, if the WC has any necessary spatial extension installed.
12011201
self._check_for_unsupported_ds_types(sess, target_datasets)
12021202

1203+
import os
1204+
1205+
if os.environ.get("NO_DROP_AND_RECREATE", None):
1206+
# Don't drop and recreate any tables - try and treat them as updates instead.
1207+
drop_and_recreate = ds_inserts & ds_deletes
1208+
ds_updates = ds_updates | drop_and_recreate
1209+
ds_inserts = ds_inserts - drop_and_recreate
1210+
ds_deletes = ds_deletes - drop_and_recreate
1211+
12031212
# Delete old tables
12041213
if ds_deletes:
12051214
self.drop_tables(target_commit, *[base_datasets[d] for d in ds_deletes])
@@ -1246,14 +1255,22 @@ def _update_table(
12461255
"""
12471256
feature_filter = ds_filter.get("feature", ds_filter.child_type())
12481257

1249-
self._apply_meta_diff(
1250-
sess, base_ds, ~self.diff_dataset_to_working_copy_meta(base_ds)
1251-
)
1258+
import os
1259+
1260+
if os.environ.get("NO_APPLY_SCHEMA_CHANGES", None):
1261+
pass
1262+
else:
1263+
self._apply_meta_diff(
1264+
sess, base_ds, ~self.diff_dataset_to_working_copy_meta(base_ds)
1265+
)
12521266
# WC now has base_ds structure and so we can write base_ds features to WC.
12531267
self._reset_dirty_rows(sess, base_ds, feature_filter)
12541268

12551269
if target_ds != base_ds:
1256-
self._apply_meta_diff(sess, target_ds, base_ds.diff_meta(target_ds))
1270+
if os.environ.get("NO_APPLY_SCHEMA_CHANGES", None):
1271+
pass
1272+
else:
1273+
self._apply_meta_diff(sess, target_ds, base_ds.diff_meta(target_ds))
12571274
# WC now has target_ds structure and so we can write target_ds features to WC.
12581275
self._apply_feature_diff(
12591276
sess, base_ds, target_ds, feature_filter, track_changes_as_dirty

0 commit comments

Comments
 (0)