-
Notifications
You must be signed in to change notification settings - Fork 24
Closed
Description
Problem Description
I have the following WhereExpr in my query, where I'm using the PostGIS ST_CoveredBy and ST_GeomFromEWKT functions in a nested fashion:
... WHERE ST_CoveredBy(coordinates, ST_GeomFromEWKT('SRID=4326;POLYGON ( '( [...] )' ) AND ...When representing this query in sqlerl, I have the following tuple:
{where, {'and', [
{call, st_coveredby,
[ coordinates, {call, st_geomfromewkt, ["SRID=4326;..."]} ]
},
...
]}
}On Erlang/OTP 17 [erts-6.4], I get the following stack trace on sqerl:unsafe_sql(Sql) where Sql contains my full sqerl tuple:
** exception error: bad argument
in function list_to_binary/1
called as list_to_binary({error,{unrecognized_value,{{call,st_geomfromtext,
["SRID=4326;..."]}}}})
in call from sqerl:encode/2 (/Users/ptrf/project/_build/default/lib/sqerl/src/sqerl.erl, line 73)
in call from sqerl:'-make_list/2-lc$^0/1-0-'/2 (/Users/ptrf/project/_build/default/lib/sqerl/src/sqerl.erl, line 348)
in call from sqerl:'-make_list/2-lc$^0/1-0-'/2 (/Users/ptrf/project/_build/default/lib/sqerl/src/sqerl.erl, line 348)
in call from sqerl:make_list/2 (/Users/ptrf/project/_build/default/lib/sqerl/src/sqerl.erl, line 348)
in call from sqerl:expr/2 (/Users/ptrf/project/_build/default/lib/sqerl/src/sqerl.erl, line 362)
in call from sqerl:'-expr/2-lc$^0/1-0-'/2 (/Users/ptrf/project/_build/default/lib/sqerl/src/sqerl.erl, line 401)
in call from sqerl:'-expr/2-lc$^0/1-0-'/2 (/Users/ptrf/project/_build/default/lib/sqerl/src/sqerl.erl, line 401)
The problem is that sqerl:param/1 opts to try encoding the call tuple, which returns the {error, {unrecognized_value,...}} tuple.
Proposed solution
As you can nest function calls in PostgreSQL, I think sqerl:param/1 should handle the case {call, FuncName, Params} by calling sqerl:expr/2 on it. This can be done as expr ignores the Safe parameter, which is not available in sqerl:param/1.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels