In a model defaultScope(), I have ‘order’= >‘someColumn’,…
The someColumn column is displayed in a CGridView.
If the user clicks on that column heading, it generates invalid SQL, because it’s trying to sort by a column that’s already in the defaultScope(). The column name is added to the ORDER BY clause twice.
The problem seems to be in CDbCriteria.MergeWith(). It merges the Order properties of the current criteria object, blindly with the new ones. Nothing is done to prevent column duplication.
What am I missing? This seems like it should be a very common problem; yet I can find nothing in the forums.