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

Issue:
Uuid.into_bytes() not present in older versions (which are listed as valid dependencies)
<!--
If you want to report a bug, we added some points below which help us track down the problem faster.
-->

## Setup

### Versions

- **Rust:**
- **Diesel:**
- **Database:**
- **Operating System**

### Feature Flags

extras, postgres

## Problem Description

Compile error against old version of uuid, which is valid given version constraint.

`Uuid.into_bytes()` wasn't actually implemented until [Feb 10](https://github.com/uuid-rs/uuid/commit/a1fd80c57ec05e47be6521646cca18ea1268333e).

`uuid = { version = ">=0.7.0, <2.0.0", optional = true }`

My version:
```
[[package]]
name = "uuid"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7"
```

### Steps to reproduce
```
cargo test --no-default-features --features "extras postgres" --                                      
   Compiling diesel v2.0.0 (/home/otto/projects/diesel/diesel)
error[E0599]: no method named `into_bytes` found for struct `uuid::Uuid` in the current scope
  --> diesel/src/pg/types/uuid.rs:44:34
   |
44 |     assert_eq!(buffer, test_uuid.into_bytes());
   |                                  ^^^^^^^^^^ method not found in `uuid::Uuid`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0599`.
error: could not compile `diesel`

To learn more, run the command again with --verbose.
```
<!--
Please include as much of your codebase as needed to reproduce the error.  If the relevant files are large, please consider linking to a public repository or a [Gist](https://gist.github.com/). This includes normally the following parts:

* The exact code where your hit the problem
* Relevant parts your schema, so any `table!` macro calls required for the
* Any other type definitions involved in the code, which produces your problem
-->




Discussion / hints:
#3137 - the relevant PR

Fix patch:
diff --git a/diesel/src/pg/types/uuid.rs b/diesel/src/pg/types/uuid.rs
index 5840d0bb05e4..2d453a450da7 100644
--- a/diesel/src/pg/types/uuid.rs
+++ b/diesel/src/pg/types/uuid.rs
@@ -41,7 +41,7 @@ fn uuid_to_sql() {
     let test_uuid = uuid::Uuid::from_slice(&bytes).unwrap();
     let mut bytes = Output::test(ByteWrapper(&mut buffer));
     ToSql::<Uuid, Pg>::to_sql(&test_uuid, &mut bytes).unwrap();
-    assert_eq!(buffer, test_uuid.into_bytes());
+    assert_eq!(&buffer, test_uuid.as_bytes());
 }
 
 #[test]
@@ -59,10 +59,18 @@ fn some_uuid_from_sql() {
 #[test]
 fn bad_uuid_from_sql() {
     let uuid = uuid::Uuid::from_sql(PgValue::for_test(b"boom"));
-    assert_eq!(
-        uuid.unwrap_err().to_string(),
-        "invalid length: expected 16 bytes, found 4"
-    );
+    assert!(uuid.is_err());
+    // The error message changes slightly between different
+    // uuid versions, so we just check on the relevant parts
+    // The exact error messages are either:
+    // "invalid bytes length: expected 16, found 4"
+    // or
+    // "invalid length: expected 16 bytes, found 4"
+    let error_message = uuid.unwrap_err().to_string();
+    assert!(error_message.starts_with("invalid"));
+    assert!(error_message.contains("length"));
+    assert!(error_message.contains("expected 16"));
+    assert!(error_message.ends_with("found 4"));
 }
 
 #[test]


Test patch: