Skip to content

Commit

Permalink
Merge branch '0.8-dev' into toolbox_2431_fix_fetching_external_modifi…
Browse files Browse the repository at this point in the history
…cations
  • Loading branch information
soininen committed Jan 11, 2024
2 parents 3e88fb4 + 0fe0362 commit 356eb61
Show file tree
Hide file tree
Showing 8 changed files with 177 additions and 144 deletions.
10 changes: 5 additions & 5 deletions spinedb_api/db_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def get_item(self, item_type, fetch=True, skip_removed=True, **kwargs):
Example::
with DatabaseMapping(db_url) as db_map:
prince = db_map.get_item("entity", class_name="musician", name="Prince")
prince = db_map.get_item("entity", entity_class_name="musician", name="Prince")
Args:
item_type (str): One of <spine_item_types>.
Expand Down Expand Up @@ -409,7 +409,7 @@ def add_item(self, item_type, check=True, **kwargs):
with DatabaseMapping(db_url) as db_map:
db_map.add_item("entity_class", name="musician")
db_map.add_item("entity", class_name="musician", name="Prince")
db_map.add_item("entity", entity_class_name="musician", name="Prince")
Args:
item_type (str): One of <spine_item_types>.
Expand Down Expand Up @@ -447,7 +447,7 @@ def update_item(self, item_type, check=True, **kwargs):
Example::
with DatabaseMapping(db_url) as db_map:
prince = db_map.get_item("entity", class_name="musician", name="Prince")
prince = db_map.get_item("entity", entity_class_name="musician", name="Prince")
db_map.update_item(
"entity", id=prince["id"], name="the Artist", description="Formerly known as Prince."
)
Expand Down Expand Up @@ -533,7 +533,7 @@ def remove_item(self, item_type, id_, check=True):
Example::
with DatabaseMapping(db_url) as db_map:
prince = db_map.get_item("entity", class_name="musician", name="Prince")
prince = db_map.get_item("entity", entity_class_name="musician", name="Prince")
db_map.remove_item("entity", prince["id"])
Args:
Expand Down Expand Up @@ -582,7 +582,7 @@ def restore_item(self, item_type, id_):
Example::
with DatabaseMapping(db_url) as db_map:
prince = db_map.get_item("entity", skip_remove=False, class_name="musician", name="Prince")
prince = db_map.get_item("entity", skip_remove=False, entity_class_name="musician", name="Prince")
db_map.restore_item("entity", prince["id"])
Args:
Expand Down
2 changes: 1 addition & 1 deletion spinedb_api/db_mapping_query_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ def ext_entity_group_sq(self):
self.entity_group_sq.c.entity_class_id.label("class_id"),
self.entity_group_sq.c.entity_id.label("group_id"),
self.entity_group_sq.c.member_id.label("member_id"),
self.wide_entity_class_sq.c.name.label("class_name"),
self.wide_entity_class_sq.c.name.label("entity_class_name"),
group_entity.c.name.label("group_name"),
member_entity.c.name.label("member_name"),
label("object_class_id", self._object_class_id()),
Expand Down
7 changes: 5 additions & 2 deletions spinedb_api/export_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,16 @@ def export_superclass_subclasses(db_map, ids=Asterisk):

def export_entities(db_map, ids=Asterisk):
return sorted(
((x.class_name, x.element_name_list or x.name, x.description) for x in _get_items(db_map, "entity", ids)),
(
(x.entity_class_name, x.element_name_list or x.name, x.description)
for x in _get_items(db_map, "entity", ids)
),
key=lambda x: (0 if isinstance(x[1], str) else len(x[1]), x[0], (x[1],) if isinstance(x[1], str) else x[1]),
)


def export_entity_groups(db_map, ids=Asterisk):
return sorted((x.class_name, x.group_name, x.member_name) for x in _get_items(db_map, "entity_group", ids))
return sorted((x.entity_class_name, x.group_name, x.member_name) for x in _get_items(db_map, "entity_group", ids))


def export_entity_alternatives(db_map, ids=Asterisk):
Expand Down
8 changes: 4 additions & 4 deletions spinedb_api/import_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def _get_superclass_subclasses_for_import(db_map, data):

def _get_entities_for_import(db_map, data):
items_by_el_count = {}
key = ("class_name", "byname", "description")
key = ("entity_class_name", "entity_byname", "description")
for class_name, name_or_el_name_list, *optionals in data:
if isinstance(name_or_el_name_list, (list, tuple)):
el_count = len(name_or_el_name_list)
Expand All @@ -520,7 +520,7 @@ def _get_entity_alternatives_for_import(db_map, data):


def _get_entity_groups_for_import(db_map, data):
key = ("class_name", "group_name", "member_name")
key = ("entity_class_name", "group_name", "member_name")
return (dict(zip(key, x)) for x in data)


Expand Down Expand Up @@ -642,7 +642,7 @@ def _get_metadata_for_import(db_map, data):


def _get_entity_metadata_for_import(db_map, data):
key = ("class_name", "entity_byname", "metadata_name", "metadata_value")
key = ("entity_class_name", "entity_byname", "metadata_name", "metadata_value")
for class_name, entity_byname, metadata in data:
if isinstance(entity_byname, str):
entity_byname = (entity_byname,)
Expand All @@ -652,7 +652,7 @@ def _get_entity_metadata_for_import(db_map, data):

def _get_parameter_value_metadata_for_import(db_map, data):
key = (
"class_name",
"entity_class_name",
"entity_byname",
"parameter_definition_name",
"metadata_name",
Expand Down
Loading

0 comments on commit 356eb61

Please sign in to comment.