spine-tools / Spine-Database-API

Database interface to Spine generic data model
https://www.tools-for-energy-system-modelling.org/
GNU Lesser General Public License v3.0
6 stars 5 forks source link

get_entity_alternative_items fails #309

Closed jkiviluo closed 7 months ago

jkiviluo commented 8 months ago

v0.8.

foo = db_generic.get_entity_alternative_items(entity_class_name="node", entity_byname=("CH4",))

And this fails with:

Traceback (most recent call last):
  File "C:\Users\prokjt\AppData\Roaming\Python\Python39\site-packages\sqlalchemy\util\_collections.py", line 210, in __getattr__
    return self._data[key]
KeyError: 'entity_class_id'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "C:\Users\prokjt\Miniconda3\envs\spi-entity\lib\site-packages\IPython\core\interactiveshell.py", line 3526, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-4-57cfcbdd22d9>", line 1, in <module>
    foo = db_generic.get_entity_alternative_items(entity_class_name="node", entity_byname=("CH4",))
  File "C:\data\spi-entity\Spine-Toolbox\src\spinedb-api\spinedb_api\db_mapping.py", line 377, in get_items
    self.do_fetch_all(item_type, **kwargs)
  File "C:\data\spi-entity\Spine-Toolbox\src\spinedb-api\spinedb_api\db_mapping_base.py", line 284, in do_fetch_all
    self.do_fetch_more(item_type, offset=0, limit=None, **kwargs)
  File "C:\data\spi-entity\Spine-Toolbox\src\spinedb-api\spinedb_api\db_mapping_base.py", line 265, in do_fetch_more
    chunk = self._get_next_chunk(item_type, offset, limit, **kwargs)
  File "C:\data\spi-entity\Spine-Toolbox\src\spinedb-api\spinedb_api\db_mapping_base.py", line 249, in _get_next_chunk
    qry = self._make_query(item_type, **kwargs)
  File "C:\data\spi-entity\Spine-Toolbox\src\spinedb-api\spinedb_api\db_mapping_base.py", line 108, in _make_query
    qry = qry.filter(getattr(sq.c, src_key) == getattr(ref_sq.c, ref_key), getattr(ref_sq.c, key) == value)
  File "C:\Users\prokjt\AppData\Roaming\Python\Python39\site-packages\sqlalchemy\util\_collections.py", line 212, in __getattr__
    raise AttributeError(key)
AttributeError: entity_class_id