-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
alpha4->5 requires to have primary key in every model/table #1706
Comments
Btw: my lines in Model could be sligtly different because I extended my Model directly in model class, but it does not interfere with this case at all and it is merged with the newest dev version. |
A couple of things here. In every abstraction there are certain conventions that end up being required. That's the nature of programming. We've done our best to make this as flexible as possible and still provide tools that your life easier than they were before. While some of the features do assume a primary key, like Entities, there are still plenty of other ways to achieve what you need with the framework. While I'll take a look at that specific situation to see if there's anything that can be made more flexible and maintain functionality, there are times when a developer needs to be flexible. Because it's a whole lot less work for you to write a migration that adds a primary key to your tables than it is for me to ensure the entire system works for this 1% use case. And I get why you might want tables like that, I do. In my day job, though, we've faced a similar situation with Laravel and the choices for us were to either fight the framework to get some features to work right, or just add a primary key to all tables and not worry about it again... I bet you can guess which way we chose. |
w.r.t #1829, this is valid case that every model should have primary key. |
@atishamte And it's this issue that prompted me to examine things and finally decide we should enforce that. :) |
Changes in Models classToArray and crud methods starts to require every model to have defined primaryKey.
In some occasions i.e. storage-like tables (where you don't want to look often like - login attempts) don't use primary keys and that case causes exception:
I think this is step back :(.
My model:
and Entity:
I don't want to judge correctness of using tables without primary keys but it is allowed to have one or two... that's why we should not force devs to use primaryKeys everywhere ... even if this is not necessary. Additional this change keeps us far from availability to use complex primary keys like :
$primaryKey = ['first_field','second_field'];
The text was updated successfully, but these errors were encountered: