title: Cannot use UUID as a primary key: Uuid: diesel::Expression is not satisfied
body: <p>I want to have a UUID field as the primary field in a Postgres table, but I get the following error:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0277]: the trait bound `uuid::Uuid: diesel::Expression` is not satisfied
   --&gt; database/src/models.rs:3:35
    |
  3 | #[derive(Debug, Clone, Queryable, Insertable)]
    |                                   ^^^^^^^^^^ the trait `diesel::Expression` is not implemented for `uuid::Uuid`
    |
    = note: required because of the requirements on the impl of `diesel::expression::AsExpression&lt;diesel::sql_types::Uuid&gt;` for `uuid::Uuid`
  </code></pre>
  
  <p>Some older questions are there about UUID with diesel but none of them are insertable and I am getting the error specifically in that. I am using diesel with actix web. </p>
  
  <p>Here is my model:</p>
  
  <pre class="lang-rust prettyprint-override"><code>use crate::schema::users;
  
  #[derive(Debug, Clone, Queryable, Insertable)]
  #[table_name="users"]
  pub struct User {
      pub id: uuid::Uuid,
      pub phone: String,
      pub name: String,
      pub password: String,
  }
  </code></pre>
  
  <p>And my table schema</p>
  
  <pre class="lang-rust prettyprint-override"><code>table! {
      users (id) {
          id -&gt; Uuid,
          name -&gt; Text,
          phone -&gt; Text,
          password -&gt; Text,
      }
  }
  </code></pre>
  
  <p>I found some old post that suggested that the field might be nullable but <code>id</code> is the <code>PRIMARY KEY</code> in my table up.sql, so it is not nullable.</p>
  
  <p>The table is generated from diesel-cli, do there doesn't seem to be any problem there.</p>
  
  <p>Here is my Cargo.toml</p>
  
  <pre><code>diesel = { version = "1.0.0", features = ["postgres", "r2d2", "uuid"] }
  uuid = { version = "0.8", features = ["v4"] }
  serde = { version = "1.0", features = ["derive"] }
  serde_json = "1.0"
  </code></pre>