SUBSTR doesn't allow negative length

issue3150
review793002
This commit is contained in:
Cédric Krier committed 2013-04-16 15:22:55 +02:00
1 parent 2e8ec5f5df
commit d4def3771b
1 file changed
+4 -1
+4 -1
View File
@@ -144,7 +144,10 @@ class Translation(ModelSQL, ModelView):
def search_model(cls, name, clause):
cursor = Transaction().cursor
cursor.execute('SELECT id FROM "%s" '
'WHERE SUBSTR(name, 1, POSITION(\',\' IN name) - 1) %s %%s' %
'WHERE SUBSTR(name, 1, '
'CASE WHEN POSITION(\',\' IN name) > 0 '
'THEN POSITION(\',\' IN name) - 1 '
'ELSE 0 END) %s %%s' %
(cls._table, clause[1]), (clause[2],))
return [('id', 'in', [x[0] for x in cursor.fetchall()])]