Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

feat(repository): make abc more general. #82

Merged
merged 1 commit into from
Nov 2, 2022

Conversation

peterschutt
Copy link
Member

The ABC was typed to accept a sqlalchemy session object. Changed to instead receive arbitrary kwargs, but if the base class actually ever receives kwargs it will error out due to super call to object.__init__().

The service object accepts arbitrary kwargs that are passed through to the repository, but doesn't care what they are.

This all means that the only thing that knows and cares about the sqlalchemy session, is the sqlalchemy repository, and that feels right.

One facet of this approach is that it makes the concept of the transaction an implementation detail. The sqlalchemy repo has the concept of session/transaction, but a repository doesn't have to understand those things. This is consistent with the testing repository implementation, so happy to see how the pattern pans out.

Closes #54

The ABC was typed to accept a sqlalchemy session object. Changed to
instead receive arbitrary kwargs, but if the base class actually ever
receives kwargs it will error out due to super call to
`object.__init__()`.

The service object accepts arbitrary kwargs that are passed through to
the repository, but doesn't care what they are.

This all means that the only thing that knows and cares about the
sqlalchemy session, is the sqlalchemy repository, and that feels right.

One facet of this approach is that it makes the concept of the
transaction an implementation detail. The sqlalchemy repo has the
concept of session/transaction, but a repository doesn't _have_ to
understand those things. This is consistent with the testing repository
implementation, so happy to see how the pattern pans out.

Closes #54
@peterschutt peterschutt merged commit e7cb3a6 into v0.2.0 Nov 2, 2022
@peterschutt peterschutt deleted the issue-54-repo-abstract-transaction branch November 2, 2022 06:24
peterschutt added a commit that referenced this pull request Nov 5, 2022
The ABC was typed to accept a sqlalchemy session object. Changed to
instead receive arbitrary kwargs, but if the base class actually ever
receives kwargs it will error out due to super call to
`object.__init__()`.

The service object accepts arbitrary kwargs that are passed through to
the repository, but doesn't care what they are.

This all means that the only thing that knows and cares about the
sqlalchemy session, is the sqlalchemy repository, and that feels right.

One facet of this approach is that it makes the concept of the
transaction an implementation detail. The sqlalchemy repo has the
concept of session/transaction, but a repository doesn't _have_ to
understand those things. This is consistent with the testing repository
implementation, so happy to see how the pattern pans out.

Closes #54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant