You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug description
Although parameters descriptions on usage of select() and selectSum() are similar on https://codeigniter.com/user_guide/database/query_builder.html, the first method accepts Arrays as input in practice while the latter does not. The easy fix could be to disallow Arrays for select(), but based on the use case for these methods I would expect alignment on acceptance of Arrays. This would prevent many occurences of the method selectSum() in case this is required.
Potential fix
I believe it could be fixed in BaseBuilder::selectSum() by checking for Arrays, looping through them and then feeding them into the method maxMinAvgSum($select, $alias, $type). Potentially this should be done also for other methods (min, max, ...) and obviously documentation should be aligned. Alternatively, this loop could be placed in a seperate method as the logic is likely the same for all these related methods (min, max, ...); only the $type fed into maxMinAvgSum($select, $alias, $type) differs.
These two methods are faux amis (false friends). They appear to have similar signatures but their usage are actually different so they can't have the same handling of parameters due to the nuances each method has.
Bug description
Although parameters descriptions on usage of select() and selectSum() are similar on https://codeigniter.com/user_guide/database/query_builder.html, the first method accepts Arrays as input in practice while the latter does not. The easy fix could be to disallow Arrays for select(), but based on the use case for these methods I would expect alignment on acceptance of Arrays. This would prevent many occurences of the method selectSum() in case this is required.
CodeIgniter 4 version
4.0.1
Affected module(s)
CodeIgniter\Database\BaseBuilder
Expected behavior, and steps to reproduce if appropriate
The below (simplified) code reproduces the issue.
Potential fix
I believe it could be fixed in BaseBuilder::selectSum() by checking for Arrays, looping through them and then feeding them into the method maxMinAvgSum($select, $alias, $type). Potentially this should be done also for other methods (min, max, ...) and obviously documentation should be aligned. Alternatively, this loop could be placed in a seperate method as the logic is likely the same for all these related methods (min, max, ...); only the $type fed into maxMinAvgSum($select, $alias, $type) differs.
Context
The text was updated successfully, but these errors were encountered: