# Sql\_query with the Uuid type

**URL:** <https://discourse.diesel.rs/t/sql-query-with-the-uuid-type/120>\
**Category:** Uncategorized\
**Created:** [October 24, 2019, 12:45pm UTC](https://discourse.diesel.rs/t/sql-query-with-the-uuid-type/120 "2019-10-24T12:45:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ked57](https://avatars.discourse-cdn.com/v4/letter/k/e79b87/32.png) [@Ked57](https://discourse.diesel.rs/u/Ked57)\
**Post date:** [October 24, 2019, 12:45pm UTC](https://discourse.diesel.rs/t/sql-query-with-the-uuid-type/120/1 "2019-10-24T12:45:58Z")

</div>

Hello,

How do you use the Uuid type with the sql\_query function ? I’ve created a model matching my query

```auto
#[derive(PartialEq, Debug, Queryable, QueryableByName)]
pub struct PostWithUserAndStatus {
    #[sql_type = "Uuid"] pub id: Uuid,
    #[sql_type = "Timestamp"] pub created_at: NaiveDateTime,
    #[sql_type = "Varchar"] pub photo_url: String,
    #[sql_type = "Varchar"] pub content: String,
    #[sql_type = "Varchar"] pub post_status: String,
    #[sql_type = "Varchar"] pub usertable_id: String,
    #[sql_type = "Varchar"] pub user_id: String, 
    #[sql_type = "Varchar"] pub user_name: String,
    #[sql_type = "Varchar"] pub firstname: String,
    #[sql_type = "Varchar"] pub lastname: String, 
    #[sql_type = "Varchar"] pub description: String,
    #[sql_type = "Varchar"] pub avatar_url: String,
    #[sql_type = "Varchar"] pub user_status: String
}

```

and I execute my query doing this

```auto
let post_result: Result<Vec<PostWithUserAndStatus>, Error> = sql_query(posts_with_user_sql)
        .load(&connection);

```

But the load function gives this error

```auto
the trait bound `uuid::Uuid: diesel::deserialize::FromSql<uuid::Uuid, diesel::pg::Pg>` is not satisfied

the trait `diesel::deserialize::FromSql<uuid::Uuid, diesel::pg::Pg>` is not implemented for `uuid::Uuid`

```

I’ve been trying to add the Serializable and Deserializable to my model derive but I got the same error

---

<div class="post-metadata">

**Author:** ![weiznich](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.diesel.rs/weiznich/32/64_2.png) [@weiznich](https://discourse.diesel.rs/u/weiznich)\
**Post date:** [October 27, 2019, 3:53pm UTC](https://discourse.diesel.rs/t/sql-query-with-the-uuid-type/120/2 "2019-10-27T15:53:42Z")

</div>

You use the wrong `Uuid` type in your `#[sql_type]` attribute. You need to use that one from `diesel::sql_types::Uuid`.
