DB: ->limit(1) in ->one()
Proposed new feature or change
Hi,
Is there a use-case where the ActiveQuery ->one() cannot/should not have an implicit ->limit(1) in it?
I vote for adding ->limit(1) to ->one().
Thoughts?
This has been discussed many times already. https://github.com/yiisoft/yii2/issues/14236 https://github.com/yiisoft/yii2/issues/13875
Yes, but it still seems not implemented, despite any solid reasons against it... Limit (1) is meant to stop the search when the condition is met (either in the where clause, or order by, etc). I briefly read through the existing threads and was not convinced of a valid use-case against adding it. Maybe I missed something?
I haven't delved into these discussions very deeply either. But I know for sure that this has been discussed a lot, and it's actually quite a complex topic. Perhaps you should take a look at this: https://github.com/yiisoft/yii2/pull/20266
Maybe you have something to say about this.
As @mspirkov said, that was already discussed, and the threads linked have the answer to the question.