From: Luke O. <lu...@me...> - 2003-03-25 19:18:21
|
Hey again - I've got a few suggestions, which I'm in the midst of implementing, and curious whether people 1) see a need and 2) have alternate implementations for these. Proposal: Each SQLObject-derived class should be able to set a default ordering of the results returned by .select()s, and (more importantly?) when accessed via a join. Our need: When retrieving objects for display, we often have one primary way that the list should be viewed. This may be a natural field, such as alpha by name, or it may be a field explicitly for client-defined order. This requires every request to remember to order by this field, and makes control of the default order de-centralized. Proposed solution: There's two possibilities: a column could say "I'm default order!", or it could be a new class-level attribute like "_defaultOrderField = 'name'". We also need to provide a mechanism to specify ascending or descending order. We are implementing the first option, with two new class-level attributes: _defaultOrderField: must be a field defined in columns, or else it will be reset to None. By default, None. _defaultOrderDirection: less likely to be used, either "DESC" or "ASC" (case-insensitive). Default is 'ASC', as in SQL 'standard'. This then requires modifications to .select, and to *Joins .performJoin methods (as joins do not use .select). If _defaultOrderField is None, the SQL is unchanged from current. Thoughts? - Luke |