indeterminate_datatype with fragment using the PosGIS
i need determine if a record its inside a polygon that its a param from the call, but returns
ERROR 42P18 (indeterminate_datatype) could not determine data type of parameter $1
and dont really know why its happening, i tried on direct sql query and works well with the format and returns the polygon, so dont know why fails with on the format
i think that maybe its injecting like POLYGON(("latitude longitude,latitude longitude")
and maybe quotes its making some conflict but dont really know, same query with same data but in direct sql its working
coordinates
its a value of type :geometry
polygon
argument its a string but in format latitude longitude,latitude longitude,...
the error generates this query of the calculation15 Replies
try adding types to the fragment call
POLYGON(("latitude longitude,latitude longitude")
it does not inject it that way
wait
ah
'POLYGON((?))'
wouldn't work I don't think. You're creating a string.
you'd want to do something like that, to create a string value the way that you want
although I think your calculation would make more sense if it took a lat/lng instead of a string of coordinatesi tried in you way but says that
%Ash.Error.Query.NoSuchFunction{function: :arg}
if you can tell me the right format to use a geometry as argument would be great!I'm not that familiar with working with geometry TBH
can I see your latest attempt please? That gave you that error?
on using this example, gives the
NoSuchFunction
errorCan you please copy your version here so I can be sure?
That is very strange
Try this please
complete exception
try that
said
invalid geometry
because on the POLYGON
call needs double (())
im trying again
nope, the same, at least its other error 🤣Still getting indeterminate types? Can you share the full error?
Also would be good if you could show the generated query in the logs/error somewhere
im on the unit tests, how can i get the query? its from a json_api call my test
Logger.configure(level: :debug)
in hte test
and run just that one test
this fragments returns
indeterminate_datatype
this returns (Postgrex.Error) ERROR XX000 (internal_error) parse error - invalid geometry
i think that i found a solution
this works removing the '
, technically the quote its for show that its an string, but injecting as var technically its a string so no needed
works now, but fails the query 🤣
but its not for compile so i think that this its solved
final calculation to found a point inside a polygon using PosGIS🤔 I'm surprsied the double quotes works TBH
just double check the query to make sure it looks good 😄