aeat.adapters.persistence.storage.sql.repository module

Typed repositories for the public storage records.

Each repository exposes a small, explicit CRUD surface against its pydantic record type from adapters.persistence.storage.sql.records. The repositories translate between the public records and the internal SQLAlchemy mapper classes from adapters.persistence.storage.sql._orm on every boundary crossing, raising RepositoryError on integrity violations or missing-row lookups.

class SqlRecordRepository(session)[source]

Bases: ABC, Generic

Abstract base class for every typed record repository.

Subclasses own a single SQLAlchemy mapper class and are responsible for converting between that mapper class and a pydantic record type.

Parameters:

session (Session)

abstractmethod list_all()[source]

Return every row as a typed pydantic record, ordered by primary key.

Return type:

list[RecordT]

abstractmethod get(record_id)[source]

Return a single row by primary key.

Parameters:

record_id (int) – Primary-key value to fetch.

Return type:

RecordT

Returns:

The typed record matching record_id.

abstractmethod upsert(record)[source]

Insert or update record and return the persisted value.

Parameters:

record (RecordT) – Pydantic record to persist. id selects update mode; otherwise a natural-key lookup decides between insert and update.

Return type:

RecordT

Returns:

The persisted typed record reflecting the on-disk state.

abstractmethod delete(record_id)[source]

Delete the row with record_id.

Parameters:

record_id (int) – Primary-key value to delete.

Raises:

RepositoryError – If no row with record_id exists.

Return type:

None

class ModeloRepository(session)[source]

Bases: SqlRecordRepository[ModeloCatalogueRecord]

Repository for ModeloCatalogueRecord.

Parameters:

session (Session)

list_all()[source]

Return every ModeloCatalogueRecord in the table, ordered by surrogate id.

Return type:

list[ModeloCatalogueRecord]

get(record_id)[source]

Return the record with surrogate id record_id.

Parameters:

record_id (int) – Surrogate primary-key value to look up.

Return type:

ModeloCatalogueRecord

Returns:

The matching ModeloCatalogueRecord.

Raises:

RepositoryError – When no row matches.

upsert(record)[source]

Insert or update record and return the persisted ModeloCatalogueRecord.

Return type:

ModeloCatalogueRecord

Parameters:

record (ModeloCatalogueRecord)

delete(record_id)[source]

Delete the record with surrogate id record_id.

Return type:

None

Parameters:

record_id (int)

class PortalRepository(session)[source]

Bases: SqlRecordRepository[PortalRecord]

Repository for PortalRecord.

Parameters:

session (Session)

list_all()[source]

Return every PortalRecord in the table, ordered by surrogate id.

Return type:

list[PortalRecord]

get(record_id)[source]

Return the record with surrogate id record_id.

Parameters:

record_id (int) – Surrogate primary-key value to look up.

Return type:

PortalRecord

Returns:

The matching PortalRecord.

Raises:

RepositoryError – When no row matches.

upsert(record)[source]

Insert or update record and return the persisted PortalRecord.

Return type:

PortalRecord

Parameters:

record (PortalRecord)

delete(record_id)[source]

Delete the record with surrogate id record_id.

Return type:

None

Parameters:

record_id (int)

class CorpusArtifactRepository(session)[source]

Bases: SqlRecordRepository[CorpusArtifactRecord]

Repository for CorpusArtifactRecord.

Parameters:

session (Session)

list_all()[source]

Return every CorpusArtifactRecord in the table, ordered by surrogate id.

Return type:

list[CorpusArtifactRecord]

get(record_id)[source]

Return the record with surrogate id record_id.

Parameters:

record_id (int) – Surrogate primary-key value to look up.

Return type:

CorpusArtifactRecord

Returns:

The matching CorpusArtifactRecord.

Raises:

RepositoryError – When no row matches.

upsert(record)[source]

Insert or update record and return the persisted CorpusArtifactRecord.

Return type:

CorpusArtifactRecord

Parameters:

record (CorpusArtifactRecord)

delete(record_id)[source]

Delete the record with surrogate id record_id.

Return type:

None

Parameters:

record_id (int)