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]¶
-
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
recordand return the persisted value.- Parameters:
record (RecordT) – Pydantic record to persist.
idselects 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_idexists.- Return type:
- class ModeloRepository(session)[source]¶
Bases:
SqlRecordRepository[ModeloCatalogueRecord]Repository for
ModeloCatalogueRecord.- Parameters:
session (Session)
- list_all()[source]¶
Return every
ModeloCatalogueRecordin the table, ordered by surrogate id.- Return type:
- 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:
- Returns:
The matching
ModeloCatalogueRecord.- Raises:
RepositoryError – When no row matches.
- upsert(record)[source]¶
Insert or update
recordand return the persistedModeloCatalogueRecord.- Return type:
- Parameters:
record (ModeloCatalogueRecord)
- class PortalRepository(session)[source]¶
Bases:
SqlRecordRepository[PortalRecord]Repository for
PortalRecord.- Parameters:
session (Session)
- list_all()[source]¶
Return every
PortalRecordin the table, ordered by surrogate id.- Return type:
- 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:
- Returns:
The matching
PortalRecord.- Raises:
RepositoryError – When no row matches.
- upsert(record)[source]¶
Insert or update
recordand return the persistedPortalRecord.- Return type:
- Parameters:
record (PortalRecord)
- class CorpusArtifactRepository(session)[source]¶
Bases:
SqlRecordRepository[CorpusArtifactRecord]Repository for
CorpusArtifactRecord.- Parameters:
session (Session)
- list_all()[source]¶
Return every
CorpusArtifactRecordin the table, ordered by surrogate id.- Return type:
- 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:
- Returns:
The matching
CorpusArtifactRecord.- Raises:
RepositoryError – When no row matches.
- upsert(record)[source]¶
Insert or update
recordand return the persistedCorpusArtifactRecord.- Return type:
- Parameters:
record (CorpusArtifactRecord)