speedup CONTAINS when un-necessary REPLACE
This commit is contained in:
@@ -1 +1 @@
|
||||
Version 2.5.1-stable+timestamp.2013.06.24.02.06.34
|
||||
Version 2.5.1-stable+timestamp.2013.06.24.14.23.41
|
||||
|
||||
+14
-5
@@ -1255,13 +1255,22 @@ class BaseAdapter(ConnectionPool):
|
||||
return '(%s LIKE %s)' % (self.expand(first),
|
||||
self.expand('%'+second, 'string'))
|
||||
|
||||
def CONTAINS(self,first,second,case_sensitive=False):
|
||||
def CONTAINS(self,first,second,case_sensitive=False):
|
||||
if first.type in ('string','text', 'json'):
|
||||
second = Expression(None,self.CONCAT('%',Expression(
|
||||
None,self.REPLACE(second,('%','%%'))),'%'))
|
||||
if isinstance(second,Expression):
|
||||
second = Expression(None,self.CONCAT('%',Expression(
|
||||
None,self.REPLACE(second,('%','%%'))),'%'))
|
||||
else:
|
||||
second = '%'+str(second).replace('%','%%')+'%'
|
||||
elif first.type.startswith('list:'):
|
||||
second = Expression(None,self.CONCAT('%|',Expression(None,self.REPLACE(
|
||||
Expression(None,self.REPLACE(second,('%','%%'))),('|','||'))),'|%'))
|
||||
if isinstance(second,Expression):
|
||||
second = Expression(None,self.CONCAT(
|
||||
'%|',Expression(None,self.REPLACE(
|
||||
Expression(None,self.REPLACE(
|
||||
second,('%','%%'))),('|','||'))),'|%'))
|
||||
else:
|
||||
second = '%|'+str(second).replace('%','%%')\
|
||||
.replace('|','||')+'|%'
|
||||
op = case_sensitive and self.LIKE or self.ILIKE
|
||||
return op(first,second)
|
||||
|
||||
|
||||
+2
-1
@@ -1791,7 +1791,8 @@ class Auth(object):
|
||||
guess = keys.get('email', 'anonymous').split('@')[0]
|
||||
keys['first_name'] = keys.get('username', guess)
|
||||
user_id = table_user.insert(**table_user._filter_fields(keys))
|
||||
user = self.user = table_user[user_id]
|
||||
user = self.user = table_user[user_id]
|
||||
print user
|
||||
if self.settings.create_user_groups:
|
||||
group_id = self.add_group(
|
||||
self.settings.create_user_groups % user)
|
||||
|
||||
Reference in New Issue
Block a user