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
wkb: github.com/lib/pq requires binary_parameters=yes #65
Comments
Thanks @vcabbage! Just to check, is your database geometry column defined as some geometry type? I can see that you might get the above error if your geometry column is stored as a |
The column is SELECT
id, ST_X(location::GEOMETRY) as lon, ST_Y(location::GEOMETRY) as lat
FROM my_table
WHERE
ST_Within(location::GEOMETRY, $1::GEOGRAPHY::GEOMETRY); (the multiple casts are due SRID mismatches, I'll admit that I'm pretty new to GIS stuff) |
I suspect that you should be using Generally speaking |
Thanks, the intention is to find all the records within a polygon, (location is a point, the $1 parameter is a polygon). I've been trying geometry and geography fields with various functions to see what performs the best (and is accurate/correct). As to the original problem, I think the error was caused by the driver passing the data as
|
Could you post the definition of your |
Sure, here's the complete migration I'm using: CREATE EXTENSION postgis;
CREATE TABLE locations (
id TEXT PRIMARY KEY,
location GEOGRAPHY(POINT),
timestamp TIMESTAMP
);
CREATE INDEX locations_location_idx ON
locations USING GIST (location);
CREATE INDEX locations_timestamp_idx ON
locations (timestamp); I tried with the location column as For completeness, I've run this on Postgres 9.6.1 and 9.6.2. Both with a locale of UTF8. When I was tracking down the problem I think I saw some posts saying that it's not an issue if the locale is LATIN1. Perhaps that explains why we've seen different behavior? |
I tried to duplicate this problem in #83, but it seems to me that
Thanks for reporting, and please re-open this issue if it looks like something might have been missed. |
Thanks @vcabbage for your patience on this issue. You were right :) |
@twpayne Not a problem! Thanks for fixing and for writing this library! |
I'm using the wkb package to query PostGIS via github.com/lib/pq. In the default configuration, the queries failed with
pq: invalid byte sequence for encoding "UTF8": 0x00
. I found that it was necessary to addbinary_parameters=yes
to the connection string. (Documented here https://godoc.org/github.com/lib/pq#hdr-Data_Types.)Just wanted to open this issue in case someone else runs into the same problem. Maybe worth a note in the documentation?
Thanks!
The text was updated successfully, but these errors were encountered: