-
Notifications
You must be signed in to change notification settings - Fork 3
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
Invalid EndianType from parseByteString #6
Comments
Hi, Are you directly parsing the wkb from the database? If you just pass your example |
@dendrei I'm using YeshQL to map my SQL queries to PostgreSQL, and I ask to return some ByteString (I tried lazy and not lazy). |
Sorry this took so long to respond to. I think "\x..." is a way to encode a single unicode character in Haskell. Maybe YeshQL is adding that I don't know. When I try and create "\x0101000000ab93331477204a4098a608707aff3440" in GHCI it returns "numeric escape sequence out of range at character '0'". If you use "0101000000ab93331477204a4098a608707aff3440" instead and treat it as a hex (base 16) representation and decode it into binary (see https://www.schoolofhaskell.com/school/to-infinity-and-beyond/pick-of-the-week/bytestring-bits-and-pieces#hex-and-base64-encoding) then it decodes correctly:
What's weird is ST_AsBinary is what we use in Hastile (using Hasql) and it returns a binary representation whereas you seem to be getting hex representation (both ByteString unfortunately). I tried looking into YeshQL but didn't get far enough along to reproduce that problem. I created a new type for the hex version so you can treat the ByteString (binary) and ByteString (hex) differently. We've added a parseHexBinary which decodes it as hex and returns a geometry if successful. Hope this makes it easier to use/understand. |
Hello,
I run into a problem with the parseByteString on a simple SQL query.
My SQL query looks like this:
I receive the LazyByteString, for instance "\x0101000000ab93331477204a4098a608707aff3440", and I try to parse it with parseByteString from wkt-geom, but it fails with the error message: "Invalid EndianType".
I'm a bit lost right now, would you be able to point me the right way to debug it?
Thanks
The text was updated successfully, but these errors were encountered: