orm icon indicating copy to clipboard operation
orm copied to clipboard

💡 Throw an exception if entity repository attribute declared twice in different entities

Open roquie opened this issue 2 years ago • 3 comments

I have an idea!

When developer declare a entity attribute like this: #[Cycle\Entity(repository: Repository\OfferHistory::class)] for more than one entity I think what need to a thrown an exception for that case. Because if we can't do this, we got an unxpected behavior with application code and it may hard to debug.

roquie avatar May 20 '22 09:05 roquie

One repository class can be used for a lot of enities. For example, default repository is universal class for all enitites.

I think it possible to make a schema checking on the application layer for this case, before Schema object initialization

roxblnfk avatar May 20 '22 09:05 roxblnfk

Hmm. That true. May be is not a bad idea to allow using default repository for everyone but restrict if user use a custom repository.

roquie avatar Jun 06 '22 10:06 roquie

We can discuss feature about new attribute to deny usage the same repository in more than one entity.

roxblnfk avatar Jun 06 '22 16:06 roxblnfk