litestar-org / advanced-alchemy

A carefully crafted, thoroughly tested, optimized companion library for SQLAlchemy
http://docs.advanced-alchemy.litestar.dev/
MIT License
218 stars 26 forks source link

Enhancement: Remove ModelT bounding to ModelProtocol #234

Closed Rey092 closed 1 month ago

Rey092 commented 2 months ago

Summary

Bounding ModelT to ModelProtocol makes it difficult to implement SQLAlchemy ORM imperative mapping and use this library Repositories together.

According to Clean Architecture, domain layer (where mapped classes would be) should not depend on any third party libraries.

I think it's unnecessary to have this bound, cuz it's limit's us in terms of mapping to a declarative one. (We can use imperative one, but only by inheriting mapped model from ModelProtocol)

Basic Example

IDK how to change things without breaking typings. 'to_dict' is ok and 'name: str' too. but how neccessery is this typings?

__table__: FromClause
__mapper__: Mapper[Any]

Drawbacks and Impact

typings would be affected