Re: [Sqlalchemy-tickets] [sqlalchemy] #723: add nullsfirst() and nullslast() column ordering operat
Brought to you by:
zzzeek
From: sqlalchemy <mi...@zz...> - 2010-09-15 17:17:50
|
#723: add nullsfirst() and nullslast() column ordering operators -------------------------+-------------------------------------------------- Reporter: zzzeek | Owner: zzzeek Type: enhancement | Status: new Priority: medium | Milestone: 0.6.xx Component: sql | Severity: minor - half an hour Keywords: | Status_field: needs a volunteer -------------------------+-------------------------------------------------- Comment(by guest): Do you mean something like that? {{{ #!python def desc(column, nulls = None): """Return a descending ``ORDER BY`` clause element. Optional argument can be one of 'first' or 'last' to produce ``NULLS LAST`` or ``NULLS FIRST`` clause. e.g.:: order_by = [desc(table1.mycol, nulls = 'first')] """ column = _UnaryExpression(column, modifier=operators.desc_op) if nulls == 'first': column = nullsfirst(column) elif nulls == 'last': column = nullslast(column) return column }}} or like that {{{ def desc(column, modifier = None): """Return a descending ``ORDER BY`` clause element. e.g.:: order_by = [desc(table1.mycol, modifier = nullsfirst)] """ column = _UnaryExpression(column, modifier=operators.desc_op) if modifier is not None: column = modifier(column) return column }}} -- Ticket URL: <http://www.sqlalchemy.org/trac/ticket/723#comment:16> sqlalchemy <http://www.sqlalchemy.org/> The Database Toolkit for Python |