-
-
Couldn't load subscription status.
- Fork 4.6k
Add QBMapper::findById #31587
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
Add QBMapper::findById #31587
Conversation
As of Nextcloud 24 it is a requirement that all tables have a primary key. This allows us to make an assumption about what a findById looks like. This is a kind-of breaking change due to the *fragile base class* problem. Therefore we need to give app devs a heads-up before this is added. E.g. by telling them to rename their existing findById methods if they want to support wider ranges of Nextcloud or drop theirs in favor of the new base class method. Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
|
We only enforce having a primary key but not the column name |
This is something we have to fix one way or the other. I just got rid of O(n) selects in user status by adding a method that works without the object and only on the id. Otherwise what julius said |
|
Alright, that is a bummer. I'll think about it then :) |
|
Can we not take a page out of Laravel's book and allow a custom property that can overwrite the default primary key id column? For example: https://codeanddeploy.com/blog/laravel/change-primary-key-and-timestamps-in-laravel-8 |
|
Could also call it "findByPrimaryKey" and then the entity/mapper has a field which specifies which fields are the PK and selects/deletes by that? |
Yes and no. Laravel makes the assumption that you have a singular key, while we also allow composite keys. Factoring in that it's not only about the column name but arity and type, I'd rather leave that to the developers. I guess we should rather have an extension of the qb mapper that only works with singular artificial integer primary keys aka the typical id. I'll do that another time. |
As of Nextcloud 24 / #31513 it is a requirement that all tables have a primary
key. This allows us to make an assumption about what a findById looks
like.
This is a kind-of breaking change due to the fragile base class
problem. Therefore we need to give app devs a heads-up before this is
added. E.g. by telling them to rename their existing findById methods if
they want to support wider ranges of Nextcloud or drop theirs in favor
of the new base class method.
I would plan to add this only for Nextcloud 25.
In the same sense we could also add
deleteByIdin addition todeleteso that rows can be deleted without a prior retrieval.Todo