Skip to content
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

sqlx::Decode<'_, Postgres> is not implemented for Geometry even when sqlx feature is enabled #4

Open
finlaydotb opened this issue Mar 8, 2024 · 1 comment

Comments

@finlaydotb
Copy link

My Cargo.toml look like this

geox = { version = "0.5.3", features = ["serde", "serde_json", "sqlx"] }

And I have a struct like this

#[derive(Debug, Clone, Eq, PartialEq)]
#[serde(rename_all = "camelCase")]
#[oai(rename_all = "camelCase")]
pub struct Place {
    pub id: Uuid,
    pub geo_location: Geometry,
}

the column type is

     Column      |           Type           | Collation | Nullable | Default
-----------------+--------------------------+-----------+----------+---------
 id              | uuid                     |           | not null |
 geo_location    | geography                |           |          |

But when I try to map in a sqlx query like this

        let assets = query
            .map(|row: PgRow| {
                let id = row.get("id");
                let geo_location = row.get("geo_location");

                Place {
                    id,
                    geo_location,
                }
            })
            .fetch_all(&self.pool)
            .await

It fails compilation

383 |                 let geo_location = row.get("geo_location");
    |                                        ^^^ the trait `sqlx::Decode<'_, Postgres>` is not implemented for `Geometry`
...
383 |                 let geo_location = row.get("geo_location");
    |                                        ^^^ the trait `sqlx::Type<Postgres>` is not implemented for `Geometry`

Any ideas on what I could be doing wrong?

@killercup
Copy link
Member

Hi, just published 0.6.0 which supports sqlx 0.7. Maybe your project is on that already so it couldn't find the traits in the right version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants