support nulls_last in sqlite
This commit is contained in:
parent
74a9b812b0
commit
36c7e95788
1 changed files with 14 additions and 1 deletions
|
@ -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):
|
||||||
|
|
Loading…
Reference in a new issue