-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Functions in Prepared Statements #3
Comments
Ah, it looks like PostGIS helpfully defines two 2-input ST_AsGeoJson functions: CREATE OR REPLACE FUNCTION ST_AsGeoJson(int4, geometry) and CREATE OR REPLACE FUNCTION ST_AsGeoJson(geometry, int4) So, as the actually helpful hint mentions, all we should need to do it typecast "integer" to a int4. Unfortunately, this is going to happen for pretty much all of the PostGIS functions. I'm not sure if there is an easy way to add type information to function arguments. I'll try to tackle this over the weekend. |
Actually it's because of these two:
and the fact that postgres can't tell if we have geom or geog when GeoSlick returns the geometry column as bytea ala ST_AsEWKB() As an experiment I tried this directly from psql: {"type":"LineString","coordinates":[[1,2,3],[4,5,6]]} gis=# SELECT ST_AsGeoJSON(ST_AsEWKB('LINESTRING(1 2 3, 4 5 6)')); As expected, this works: gis=# SELECT ST_AsGeoJSON(ST_AsEWKB('LINESTRING(1 2 3, 4 5 6)')::GEOMETRY); {"type":"LineString","coordinates":[[1,2,3],[4,5,6]]} I tried to add the cast to GEOMETRY in GeoSlick, but I could not figure out how to do it. As an experiment I commented out the call to wrapEWKB in postgis.scala and it works for my purposes -- not sure what it breaks. Any hints on casting would be appreciated. I think it should be possible. |
I've been trying to use geom.asGeoJson() in a query that gets turned into a prepared statement. The problem is that I get
ERROR: function st_asgeojson(bytea, integer) is not unique at character 31
HINT: Could not choose a best candidate function. You might need to add explicit type casts.
in my Postgres logs.
Here's what Postgres is trying to do:
STATEMENT: select x2."name", x2."state", ST_AsGeoJson(ST_AsEWKB(x2."geom"),1), x2."country", x3."email", x4."term", x5."career" from "term" x4, "career" x5, "cities" x2, "students" x3 where (((x4."term" = $1) and (x5."career" = $2)) and (x2."id" = $3)) and (((x3."city" = x2."id") and (x3."term" = x4."id")) and (x3."career" = x5."id"))
The query works wonderfully if it's not in a prepared statement.
The text was updated successfully, but these errors were encountered: