versión 0.19
This commit is contained in:
@@ -8,7 +8,7 @@ PYTHON3 = True
|
|||||||
if sys.version_info[0] < 3:
|
if sys.version_info[0] < 3:
|
||||||
PYTHON3 = False
|
PYTHON3 = False
|
||||||
|
|
||||||
VERSION = "0.0.18"
|
VERSION = "0.0.19"
|
||||||
|
|
||||||
|
|
||||||
def is_map(obj):
|
def is_map(obj):
|
||||||
@@ -227,7 +227,9 @@ class Q(QMixin):
|
|||||||
)
|
)
|
||||||
return self._process(column, value)
|
return self._process(column, value)
|
||||||
else:
|
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():
|
if lookup in self.op_map.keys():
|
||||||
return "{0}{1}{2}".format(
|
return "{0}{1}{2}".format(
|
||||||
@@ -318,7 +320,7 @@ class SQLQuery(object):
|
|||||||
|
|
||||||
def exclude(self, *args, **kwargs):
|
def exclude(self, *args, **kwargs):
|
||||||
clone = self._clone()
|
clone = self._clone()
|
||||||
clone._excludes &= self._q(*args, **kwargs)
|
clone._excludes |= self._q(*args, **kwargs)
|
||||||
return clone
|
return clone
|
||||||
|
|
||||||
def order_by(self, *args):
|
def order_by(self, *args):
|
||||||
@@ -371,9 +373,7 @@ class SQLCompiler(object):
|
|||||||
if where:
|
if where:
|
||||||
return " AND ".join(where)
|
return " AND ".join(where)
|
||||||
|
|
||||||
def get_table(
|
def get_table(self):
|
||||||
self,
|
|
||||||
):
|
|
||||||
return self._table
|
return self._table
|
||||||
|
|
||||||
def get_where(self):
|
def get_where(self):
|
||||||
@@ -439,7 +439,11 @@ class SQLCompiler(object):
|
|||||||
return ""
|
return ""
|
||||||
|
|
||||||
def get_top(self):
|
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)
|
return "TOP {0}".format(self._limits.stop)
|
||||||
|
|
||||||
def get_sql_structure(self):
|
def get_sql_structure(self):
|
||||||
@@ -479,7 +483,9 @@ class SQLCompiler(object):
|
|||||||
conds.append("row_number <= %s" % self._limits.stop)
|
conds.append("row_number <= %s" % self._limits.stop)
|
||||||
|
|
||||||
conds = " AND ".join(conds)
|
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 [
|
return [
|
||||||
"SELECT * FROM (",
|
"SELECT * FROM (",
|
||||||
@@ -487,18 +493,22 @@ class SQLCompiler(object):
|
|||||||
",".join([paginate, self.get_columns()]),
|
",".join([paginate, self.get_columns()]),
|
||||||
"FROM",
|
"FROM",
|
||||||
table,
|
table,
|
||||||
|
self.get_nolock(),
|
||||||
self.get_joins(),
|
self.get_joins(),
|
||||||
self.get_where(),
|
self.get_where(),
|
||||||
self.get_group_by(),
|
self.get_group_by(),
|
||||||
self.get_limits(),
|
self.get_limits(),
|
||||||
") as tbl_paginated WHERE ",
|
") as tbl_paginated ",
|
||||||
|
" WHERE ",
|
||||||
conds,
|
conds,
|
||||||
]
|
]
|
||||||
|
|
||||||
return sql
|
return sql
|
||||||
|
|
||||||
def _compile(self):
|
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):
|
def __repr__(self):
|
||||||
return self._compile()
|
return self._compile()
|
||||||
|
|||||||
Reference in New Issue
Block a user