sfackler / rust-postgres

Native PostgreSQL driver for the Rust programming language
Apache License 2.0
3.52k stars 446 forks source link

How to get geo point (`GEOMETRY(Point, 4326)`) ? #1174

Closed nurmohammed840 closed 3 months ago

nurmohammed840 commented 3 months ago

My schema look like this:

CREATE TABLE IF NOT EXISTS "Post" (
    post_location GEOMETRY(Point, 4326) NOT NULL, -- Geographic coordinate system
    ...
);
let _:  geo_types::Point<f64> = row.try_get("post_location")?;
    Error {
        kind: FromSql(1),
        cause: Some(
            WrongType {
                postgres: Other(
                    Other {
                        name: "geometry",
                        oid: 17566,
                        kind: Simple,
                        schema: "public",
                    },
                ),
                rust: "geo_types::geometry::point::Point",
            },
        ),
    }

How do i get this value?

nurmohammed840 commented 3 months ago

I guess you need to convert GEOMETRY into Point in SELECT expr