Commit 8bf3d876 authored by Vincent Michel's avatar Vincent Michel
Browse files

[schema] Add some Postgres functions

parent 43e2135ec62f
/* -*- 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 $$
BEGIN
return ar1[indice];
END;
$$ LANGUAGE plpgsql;
\ No newline at end of file
## from cubicweb.schema import CONSTRAINTS
## from cubes.postgis.schema import params
## CONSTRAINTS.update((v.__name__, v) for v in params.values())
from logilab.database import FunctionDescr
from rql.utils import register_function
class VALUE(FunctionDescr):
minargs = 2
maxargs = 2
supported_backends = ('postgres',)
rtype = 'Float'
register_function(VALUE)
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