support nulls_last in sqlite

This commit is contained in:
j 2013-10-11 20:12:23 +02:00
parent 74a9b812b0
commit 36c7e95788

View file

@ -25,7 +25,20 @@ class SQLCompiler(SQLCompiler):
def get_ordering(self): def get_ordering(self):
result, group_by = super(SQLCompiler, self).get_ordering() result, group_by = super(SQLCompiler, self).get_ordering()
if self.query.nulls_last and len(result): if self.query.nulls_last and len(result):
result = map(lambda e: e + ' NULLS LAST', result) if self.connection.vendor == 'sqlite':
_result = []
for r in result:
if r.endswith(' DESC'):
_r = r[:-len(' DESC')]
elif r.endswith(' ASC'):
_r = r[:-len(' ASC')]
_result.append(_r + ' IS NULL')
_result.append(r)
result = _result
else:
result = map(lambda e: e + ' NULLS LAST', result)
print result
return result, group_by return result, group_by
class Query(Query): class Query(Query):