Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d39d96537f |
@@ -8,7 +8,7 @@ PYTHON3 = True
|
||||
if sys.version_info[0] < 3:
|
||||
PYTHON3 = False
|
||||
|
||||
VERSION = "0.0.18"
|
||||
VERSION = "0.0.19"
|
||||
|
||||
|
||||
def is_map(obj):
|
||||
@@ -227,7 +227,9 @@ class Q(QMixin):
|
||||
)
|
||||
return self._process(column, value)
|
||||
else:
|
||||
return "DATEPART({0}, {1})={2}".format(lookup, column, value)
|
||||
return "DATEPART({0}, {1})={2}".format(
|
||||
lookup, column, value
|
||||
)
|
||||
|
||||
if lookup in self.op_map.keys():
|
||||
return "{0}{1}{2}".format(
|
||||
@@ -318,7 +320,7 @@ class SQLQuery(object):
|
||||
|
||||
def exclude(self, *args, **kwargs):
|
||||
clone = self._clone()
|
||||
clone._excludes &= self._q(*args, **kwargs)
|
||||
clone._excludes |= self._q(*args, **kwargs)
|
||||
return clone
|
||||
|
||||
def order_by(self, *args):
|
||||
@@ -371,9 +373,7 @@ class SQLCompiler(object):
|
||||
if where:
|
||||
return " AND ".join(where)
|
||||
|
||||
def get_table(
|
||||
self,
|
||||
):
|
||||
def get_table(self):
|
||||
return self._table
|
||||
|
||||
def get_where(self):
|
||||
@@ -439,7 +439,11 @@ class SQLCompiler(object):
|
||||
return ""
|
||||
|
||||
def get_top(self):
|
||||
if self._limits and self.sql_mode == "SQL_SERVER" and not self._limits.start:
|
||||
if (
|
||||
self._limits
|
||||
and self.sql_mode == "SQL_SERVER"
|
||||
and not self._limits.start
|
||||
):
|
||||
return "TOP {0}".format(self._limits.stop)
|
||||
|
||||
def get_sql_structure(self):
|
||||
@@ -479,7 +483,9 @@ class SQLCompiler(object):
|
||||
conds.append("row_number <= %s" % self._limits.stop)
|
||||
|
||||
conds = " AND ".join(conds)
|
||||
paginate = "ROW_NUMBER() OVER (%s) as row_number" % self.get_order_by()
|
||||
paginate = (
|
||||
"ROW_NUMBER() OVER (%s) as row_number" % self.get_order_by()
|
||||
)
|
||||
|
||||
return [
|
||||
"SELECT * FROM (",
|
||||
@@ -487,18 +493,22 @@ class SQLCompiler(object):
|
||||
",".join([paginate, self.get_columns()]),
|
||||
"FROM",
|
||||
table,
|
||||
self.get_nolock(),
|
||||
self.get_joins(),
|
||||
self.get_where(),
|
||||
self.get_group_by(),
|
||||
self.get_limits(),
|
||||
") as tbl_paginated WHERE ",
|
||||
") as tbl_paginated ",
|
||||
" WHERE ",
|
||||
conds,
|
||||
]
|
||||
|
||||
return sql
|
||||
|
||||
def _compile(self):
|
||||
return " ".join([ensureUtf(item) for item in self.get_sql_structure() if item])
|
||||
return " ".join(
|
||||
[ensureUtf(item) for item in self.get_sql_structure() if item]
|
||||
)
|
||||
|
||||
def __repr__(self):
|
||||
return self._compile()
|
||||
|
||||
Reference in New Issue
Block a user