aiidateam / aiida-core

The official repository for the AiiDA code
https://aiida-core.readthedocs.io
Other
413 stars 184 forks source link

`SqliteDosStorage`: Fix exception when importing archive #6359

Closed sphuber closed 2 months ago

sphuber commented 2 months ago

Fixes #6316 Fixes #5735 (not directly, but think it should be resolved now)

When an archive was imported into an SqliteDosStorage backend an exception was raised by sqlalchemy. It was treating the uuid column of the models as a UUID type but in reality it was a string. This is because the storage plugin inherits the implementation largely from the core.psql_dos plugin, but it converts the models, since the UUID types that are used by the PostgreSQL implementation are not supported by SQLite.

The problem was that for archive importing, the bulk_insert method was used, which calls the _get_mapper_from_entity method to map a given ORM entity to the corresponding database model. But since this method was inherited from core.psql_dos, it was returning the incorrect models. The problem is fixed by overriding it in SqliteDosStorage and returning the SQLite-adapted models.