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

bug(typing): GenericMockRepository and Service generic type too narrow #170

Closed
peterschutt opened this issue Dec 16, 2022 · 2 comments
Closed

Comments

@peterschutt
Copy link
Member

There is no reason that applications built on this lib must be modelled on SQLAlchemy.. if there is no reason for the app to use database storage it makes no sense to enforce it.

This means that it is wrong to have Service and GenericMockRepository bound to DeclarativeBase via repository.types.ModelT as we do.

The only requirement for Service is that the repository type has to support the type supported by the service object.

Perhaps we need a Service and RepositoryService type as well, that would allow creating service objects without having to worry about repositories when they aren't needed (i.e., apps without persistent storage).

peterschutt added a commit that referenced this issue Dec 16, 2022
The coupling between the base service object and a repository type was
too inflexible to be useful when building an app that doesn't need a
repository.

`service.Service` is no longer aware of `repository_type` and has no
default implementations defined.

To get the same behavior as previous versions, service objects should
now inherit from `service.RepositoryService`.

This is for #170, but #170 is broader than this change. We still need
to make the repository service not _need_ to use SQLAlchemy ORM types
as the model type.
@peterschutt
Copy link
Member Author

Perhaps we need a Service and RepositoryService type as well, that would allow creating service objects without having to worry about repositories when they aren't needed (i.e., apps without persistent storage).

This is done in #171 - but the rest of this still needs to be done.

peterschutt added a commit that referenced this issue Dec 16, 2022
The coupling between the base service object and a repository type was
too inflexible to be useful when building an app that doesn't need a
repository.

`service.Service` is no longer aware of `repository_type` and has no
default implementations defined.

To get the same behavior as previous versions, service objects should
now inherit from `service.RepositoryService`.

This is for #170, but #170 is broader than this change. We still need
to make the repository service not _need_ to use SQLAlchemy ORM types
as the model type.
peterschutt added a commit that referenced this issue Dec 16, 2022
`service.Service` is no longer aware of `repository_type` and has no
default implementations defined.

The coupling between the base service object and a repository type was
too inflexible to be useful when building an app that doesn't need a
repository.

To get the same behavior as previous versions, service objects should
now inherit from `service.RepositoryService`.

This is for #170, but #170 is broader than this change. We still need
to make the repository service not _need_ to use SQLAlchemy ORM types
as the model type.
@peterschutt
Copy link
Member Author

The other stuff about not having the generic mock repository typed to orm.Base falls apart as we rely on id, created and updated attributes.. so forgetting about the rest of this for now.

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

No branches or pull requests

1 participant