-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
Pickle doesn't like negative numbers.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -479,6 +479,9 @@ def import_from_json(self, file_path): | |
except json.decoder.JSONDecodeError as err: | ||
self.msg_error.emit(f"File {file_path} is not a valid json: {err}") | ||
return | ||
with DatabaseMapping("sqlite://", create=True) as db_map: | ||
import_data(db_map, **data) | ||
data = export_data(db_map) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
manuelma
Author
Collaborator
|
||
self.import_data(data) | ||
filename = os.path.split(file_path)[1] | ||
self.msg.emit(f"File {filename} successfully imported.") | ||
|
@@ -534,16 +537,13 @@ def _clean_up_export_items_dialog(self): | |
|
||
@Slot(bool) | ||
def export_session(self, checked=False): | ||
"""Exports changes made in the current session as reported by DiffDatabaseMapping.""" | ||
db_map_diff_ids = {db_map: db_map.diff_ids() for db_map in self.db_maps} # FIXME: diff_ids() | ||
db_map_ent_cls_ids = {db_map: diff_ids["entity_class"] for db_map, diff_ids in db_map_diff_ids.items()} | ||
db_map_ent_ids = {db_map: diff_ids["entity"] for db_map, diff_ids in db_map_diff_ids.items()} | ||
db_map_par_val_lst_ids = { | ||
db_map: diff_ids["parameter_value_list"] for db_map, diff_ids in db_map_diff_ids.items() | ||
} | ||
db_map_par_def_ids = {db_map: diff_ids["parameter_definition"] for db_map, diff_ids in db_map_diff_ids.items()} | ||
db_map_par_val_ids = {db_map: diff_ids["parameter_value"] for db_map, diff_ids in db_map_diff_ids.items()} | ||
db_map_ent_group_ids = {db_map: diff_ids["entity_group"] for db_map, diff_ids in db_map_diff_ids.items()} | ||
"""Exports changes made in the current session.""" | ||
db_map_ent_cls_ids = {db_map: db_map.cache.dirty_ids("entity_class") for db_map in self.db_maps} | ||
db_map_ent_ids = {db_map: db_map.cache.dirty_ids("entity") for db_map in self.db_maps} | ||
db_map_par_val_lst_ids = {db_map: db_map.cache.dirty_ids("parameter_value_list") for db_map in self.db_maps} | ||
db_map_par_def_ids = {db_map: db_map.cache.dirty_ids("parameter_definition") for db_map in self.db_maps} | ||
db_map_par_val_ids = {db_map: db_map.cache.dirty_ids("parameter_value") for db_map in self.db_maps} | ||
db_map_ent_group_ids = {db_map: db_map.cache.dirty_ids("entity_group") for db_map in self.db_maps} | ||
parcel = SpineDBParcel(self.db_mngr) | ||
parcel.push_entity_class_ids(db_map_ent_cls_ids) | ||
parcel.push_entity_ids(db_map_ent_ids) | ||
|
@manuelma Do you recall why you added these lines here? With this detour, you cannot import e.g. a json that contains entities only because the empty temporary database does not contain entity classes, see #2725.