MechanicalRabbit / FunSQL.jl

Julia library for compositional construction of SQL queries
https://mechanicalrabbit.github.io/FunSQL.jl
Other
144 stars 5 forks source link

Make built-in SQL functions and operators available in @funsql macro #53

Open xitology opened 5 months ago

xitology commented 5 months ago

For use with @funsql macro, FunSQL currently exports a small number of common SQL functions and operators:

Any SQL function not in these lists has to be declared like this:

const var"funsql_%" = FunSQL.Fun."%"
const funsql_array_get = FunSQL.Fun."?[?]"
const funsql_as_integer = FunSQL.Fun."(?::integer)"
const funsql_bool_and = FunSQL.Agg.bool_and
const funsql_regexp_matches = FunSQL.Fun.regexp_matches
const funsql_string_agg = FunSQL.Agg."string_agg(?, NULL ORDER BY ?)"

Ideally, FunSQL should provide all built-in functions and operators, for every supported database engine. Since every engine has its own list of supported functions, these declarations could be added to engine-specific modules:

using FunSQL, FunSQL.PostgreSQL
@funsql select(as_integer("0")) #-> SELECT ('0'::integer)