Commit 26999e0f authored by Adrien Di Mascio's avatar Adrien Di Mascio
Browse files

Rename VALUE to ARRAY_GET, declare rql to sql mapping directly in FunctionDescr (closes #3036180)

parent 4cb35994be73
/* -*- sql -*-
postgres specific registered procedures,
require the plpgsql language installed
add the VALUE function to be able to query the postgres arrays
in RQL query, example below:
Any X WHERE X is TimeSerie, X serie S HAVING VALUE(S, 10)>3
CREATE OR REPLACE FUNCTION VALUE(ar1 integer[], indice integer) RETURNS float
AS $$
return ar1[indice];
$$ LANGUAGE plpgsql;
\ No newline at end of file
......@@ -40,11 +40,14 @@ sqlitehelper.TYPE_CONVERTERS['FloatArray'] = json.dumps
from rql.utils import register_function
class VALUE(FunctionDescr):
class ARRAY_GET(FunctionDescr):
minargs = 2
maxargs = 2
supported_backends = ('postgres',)
rtype = 'Float'
def as_sql_postgres(self, args):
return "%s[%s]" % (args[0], args[1])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment