From ff2ea63a63231163885ad8da6d2a83a8c6b64445 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Sun, 20 Dec 2015 11:42:17 -0700 Subject: [PATCH] Ensure `Vec` can be used in `#[changeset_for]` Usually we implement all the various `AsExpression` for refs in the `expression_impls!` macro. However, that macro doesn't work with generics, and we forgot to handle `Vec` (I think I figured the slice impl was enough for some reason). I tried to write a test for this change, but there are actually several other bugs that prevent me from testing this properly. See #65 & #66. Fixes #63. --- CHANGELOG.md | 5 +++++ diesel/src/types/impls/array.rs | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c2dee297171f..1af9981b3497 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,11 @@ for Rust libraries in [RFC #1105](https://github.com/rust-lang/rfcs/blob/master/ * Add print_sql! and debug_sql! macros to print out and return sql strings from QueryFragments. +### Fixed + +* `#[changeset_for]` can now be used with structs containing a `Vec`. Fixes + [#63](https://github.com/sgrif/diesel/issues/63). + ## [0.3.0] 2015-12-04 ### Changed diff --git a/diesel/src/types/impls/array.rs b/diesel/src/types/impls/array.rs index 08263b94abe5..2db28d9f659c 100644 --- a/diesel/src/types/impls/array.rs +++ b/diesel/src/types/impls/array.rs @@ -90,6 +90,17 @@ impl AsExpression> for Vec where } } +impl<'a, ST, T> AsExpression> for &'a Vec where + ST: NativeSqlType, + T: ToSql, +{ + type Expression = Bound, Self>; + + fn as_expression(self) -> Self::Expression { + Bound::new(self) + } +} + impl<'a, ST, T> ToSql> for &'a [T] where ST: NativeSqlType, T: ToSql,