I'm trying to query a PostgreSQL database table using sqlx. But, the following error is shown
[rustc] [E] optional feature `uuid` required for type UUID of column #1 ("id")
My code snippet
use sqlx::{Pool, Postgres, postgres::PgRow, Row, FromRow};
use uuid::Uuid;
#[derive(FromRow)]
struct User {
id: uuid::fmt::Hyphenated
}
let result = sqlx::query_as!(User, "SELECT id FROM users")
.fetch_one(pool)
.await
.expect("QUERY FAILED");
SQL
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE TABLE IF NOT EXISTS users (
id uuid DEFAULT uuid_generate_v4(),
PRIMARY KEY (id)
);
Any idea how to resolve an error?