fixed a problem with SQLCustomType, thanks Fran and Michele
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 1.99.3 (2011-12-13 15:16:17) stable
|
Version 1.99.3 (2011-12-13 15:21:08) stable
|
||||||
|
|||||||
+9
-6
@@ -5889,15 +5889,15 @@ class Expression(object):
|
|||||||
return Query(self.db, self.db._adapter.ENDSWITH, self, value)
|
return Query(self.db, self.db._adapter.ENDSWITH, self, value)
|
||||||
|
|
||||||
def contains(self, value, all=False):
|
def contains(self, value, all=False):
|
||||||
if isinstance(value,(list,tuple)):
|
if isinstance(value,(list, tuple)):
|
||||||
subqueries = [self.contains(str(v).strip()) for v in value if str(v).strip()]
|
subqueries = [self.contains(str(v).strip()) for v in value if str(v).strip()]
|
||||||
return reduce(all and AND or OR, subqueries)
|
return reduce(all and AND or OR, subqueries)
|
||||||
if not self.type in ('string', 'text') and not self.type.startswith('list:'):
|
if not self.type in ('string', 'text') and not self.type.startswith('list:'):
|
||||||
raise SyntaxError, "contains used with incompatible field type"
|
raise SyntaxError, "contains used with incompatible field type"
|
||||||
return Query(self.db, self.db._adapter.CONTAINS, self, value)
|
return Query(self.db, self.db._adapter.CONTAINS, self, value)
|
||||||
|
|
||||||
def with_alias(self,alias):
|
def with_alias(self, alias):
|
||||||
return Expression(self.db,self.db._adapter.AS,self,alias,self.type)
|
return Expression(self.db, self.db._adapter.AS, self, alias, self.type)
|
||||||
|
|
||||||
# for use in both Query and sortby
|
# for use in both Query and sortby
|
||||||
|
|
||||||
@@ -5946,7 +5946,10 @@ class SQLCustomType(object):
|
|||||||
self._class = _class or type
|
self._class = _class or type
|
||||||
|
|
||||||
def startswith(self, text=None):
|
def startswith(self, text=None):
|
||||||
return self.type.startswith(self,text)
|
try:
|
||||||
|
return self.type.startswith(self, text)
|
||||||
|
except TypeError:
|
||||||
|
return False
|
||||||
|
|
||||||
def __getslice__(self, a=0, b=100):
|
def __getslice__(self, a=0, b=100):
|
||||||
return None
|
return None
|
||||||
@@ -5958,11 +5961,11 @@ class SQLCustomType(object):
|
|||||||
return self._class
|
return self._class
|
||||||
|
|
||||||
class FieldVirtual(object):
|
class FieldVirtual(object):
|
||||||
def __init__(self,f):
|
def __init__(self, f):
|
||||||
self.f = f
|
self.f = f
|
||||||
|
|
||||||
class FieldLazy(object):
|
class FieldLazy(object):
|
||||||
def __init__(self,f,handler=None):
|
def __init__(self, f, handler=None):
|
||||||
self.f = f
|
self.f = f
|
||||||
self.handler = handler
|
self.handler = handler
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user