summaryrefslogtreecommitdiff
path: root/adbh.py
diff options
context:
space:
mode:
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>2008-07-24 18:05:40 +0200
committerAdrien Di Mascio <Adrien.DiMascio@logilab.fr>2008-07-24 18:05:40 +0200
commitda452d3ec2f0673cdcedba88f4c2927b0fe02749 (patch)
tree259b0c69bdbb7a766d38dc1ef39473f7f63744d0 /adbh.py
parent1d9a9b267d06973ae0ba1a0d65225afe00d17fbf (diff)
downloadlogilab-common-da452d3ec2f0673cdcedba88f4c2927b0fe02749.tar.gz
[adbh] define the RANDOM function
Diffstat (limited to 'adbh.py')
-rw-r--r--adbh.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/adbh.py b/adbh.py
index 34756dc..880eb8b 100644
--- a/adbh.py
+++ b/adbh.py
@@ -88,6 +88,14 @@ class LENGTH(FunctionDescr):
class DATE(FunctionDescr):
rtype = 'Date'
+class RANDOM(FunctionDescr):
+ supported_backends = ('postgres', 'mysql',)
+ rtype = 'Float'
+ minargs = maxargs = 0
+ name_mapping = {'postgres': 'RANDOM',
+ 'mysql': 'RAND',
+ }
+
class _GenericAdvFuncHelper:
"""Generic helper, trying to provide generic way to implement
specific functionnalities from others DBMS
@@ -113,6 +121,7 @@ class _GenericAdvFuncHelper:
'UPPER': UPPER, 'LOWER': LOWER,
'LENGTH': LENGTH,
'DATE': DATE,
+ 'RANDOM': RANDOM,
# keyword function
'IN': IN
}
@@ -405,7 +414,8 @@ class _SqliteAdvFuncHelper(_GenericAdvFuncHelper):
backend_name = 'sqlite'
# modifiable but should not be shared
FUNCTIONS = _GenericAdvFuncHelper.FUNCTIONS.copy()
-
+ FUNCTIONS.pop('RANDOM') # not defined in sqlite
+
users_support = groups_support = False
ilike_support = False
union_parentheses_support = False