Welcome Guest, Not a member yet? Register   Sign In
Poll: Do you think this would be helpful?
You do not have permission to vote in this poll.
Yes
50.00%
3 50.00%
No
33.33%
2 33.33%
I don't use Soft Deletes
16.67%
1 16.67%
Total 6 vote(s) 100%
* You voted for this item. [Show Results]

Query Builder Soft Deletes
#1
Lightbulb 

It would be extremely helpful if Soft Deletes were ALSO supported in Query Builder, and not exclusively to Model/BaseModel.

The current "method" of always having to remember to include where('deleted_at IS NULL') feels like a hack/workaround, like Builder is unfinished.

Thanks!  And thank you for all of the hard work! ??

Bridging the gap between Technical and Creative

VASCOsoft Web Studio   |   AllMyLinks

Reply
#2

CI developer team should please think about this feature.
Reply
#3

This isn't the first time this has come up. I understand the interest, but this is really bleeding together very different aspects of two components. Query Builder is our database abstraction layer: it lets use write object-oriented methods and have them interact with the database. Most importantly, it is completely structure agnostic - it knows nothing about what is in the database it interacts with. Models (ideally) are the inverse: they provide a concept of data structure without having to know how to interact with the database itself. In practice the Model does some SQL-fu, but that's out of necessity.
Convenience aside, it is a really bad idea (in my opinion) to make Query Builder aware/reliant on any particular data structure in the database. In order to "support soft deletes" Query Builder not only needs to know which tables are "entities", but it also needs to know which fields indicate deletion (like deleted_at) and what type of field that is (nullable, some time representation). At this point what you're doing is taking what makes Model a valuable class and muddying it into Builder.
Reply
#4

I agree with MGatner. It doesn't belong in the query builder. The builder is exactly that, a class to build generic SQL queries. It knows nothing about the business logic of your app and what column do what. Especially in the case where the "deleted_at" column has a different name. Also it would be even more confusing if I do a select(*) and it doesn't return everything because it decided to exclude the soft deleted rows.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply




Theme © iAndrew 2016 - Forum software by © MyBB