Repository: diesel-rs/diesel (language: rust)

Issue:
serialize_as skips UndecoratedInsertRecord implementation
## Setup

### Versions

- **Rust:** 1.50.0
- **Diesel:** master
- **Database:** mysql
- **Operating System** macOS 11

### Feature Flags

- **diesel:** mysql, r2d2, chrono

## Problem Description
The `UndecoratedInsertRecord` marker [implementation is not included](https://github.com/diesel-rs/diesel/commit/a2996ee4f7f399e7b66449afa98c910ab23867fb#diff-fa14d901408aeec9013f13ab3f012dc73ab9766d9caa5a4981da18694bb0c555R93) when using `#[diesel(serialize_as="...")]`, it is skipped alongside the (correctly skipped) borrowed insert impl as discussed by @thomaseizinger [here](https://github.com/diesel-rs/diesel/pull/2553#issuecomment-720757757).

As such, this makes it impossible to [insert a `Vec<T>`](https://github.com/diesel-rs/diesel/blob/ccfc42a1e9098fd1e288d701b6a2a832a88a6f9a/diesel/src/insertable.rs#L224) of anything that uses `serialize_as`.

Is this indeed a mistake, or am I missing some reason for why this isn't allowed?

### Steps to reproduce
Following my [conversation on Gitter](https://gitter.im/diesel-rs/diesel?at=60512153e8267a46f21cc28a), in a simple `Insertable` derived struct, using `serialize_as` like so:

```rust
#[derive(Insertable)]
#[table_name = "..."]
pub struct Example {
  // ...
  #[diesel(serialize_as = "OptionalSQLUTCDateTime")]
  pub last_play: Option<DateTime<Utc>>,
}
```

...renders `impl<'insert> Insertable<...> for Example {`

However, not using `serialize_as`, like so:

```rust
#[derive(Insertable)]
#[table_name = "..."]
pub struct Example {
  // ...
  pub last_play: OptionalSQLUTCDateTime,
}
```

...renders `impl<'insert> Insertable<...> for Example {`, `impl<'insert> Insertable<...> for &'insert Example {` and importantly `impl<'insert> UndecoratedInsertRecord<...> for Example {}`


Discussion / hints:
That's an oversight of the original PR. We are happy to receive a fix for that as PR.

Fix patch:
diff --git a/diesel_derives/src/insertable.rs b/diesel_derives/src/insertable.rs
index d6a7374f1876..25e6a35bc956 100644
--- a/diesel_derives/src/insertable.rs
+++ b/diesel_derives/src/insertable.rs
@@ -89,12 +89,6 @@ pub fn derive(item: syn::DeriveInput) -> Result<proc_macro2::TokenStream, Diagno
                     (#(#ref_field_assign,)*).values()
                 }
             }
-
-            impl #impl_generics UndecoratedInsertRecord<#table_name::table>
-                for #struct_name #ty_generics
-            #where_clause
-            {
-            }
         }
     } else {
         quote! {}
@@ -108,6 +102,12 @@ pub fn derive(item: syn::DeriveInput) -> Result<proc_macro2::TokenStream, Diagno
         #insert_owned
 
         #insert_borrowed
+
+        impl #impl_generics UndecoratedInsertRecord<#table_name::table>
+                for #struct_name #ty_generics
+            #where_clause
+        {
+        }
     }))
 }
 


Test patch: