Replies: 5 comments 7 replies
-
It's certainly possible to implement these traits in diesel, although it's not clear if that's really what we as maintainers want to do. Can you present your usecase why that would be required and also describe how these values would be represented at database level? The general guidelines for type mappings in diesel are as following:
|
Beta Was this translation helpful? Give feedback.
-
Hello,
best regards |
Beta Was this translation helpful? Give feedback.
-
Hello, Sorry for the late reply.
I did not really understand what you mean here ? Well In fact after more test #[diesel(serialize_as = Vec< u8 >)] is not enough because when I add Queryable & Insertable it doesn't work anymore :( |
Beta Was this translation helpful? Give feedback.
-
About possible failure : So the function #[cfg(unix)] {
use std::ffi::OsStr;
use std::os::unix::ffi::OsStrExt;
// Here, the values 0x66 and 0x6f correspond to 'f' and 'o'
// respectively. The value 0x80 is a lone continuation byte, invalid
// in a UTF-8 sequence.
let source = [0x66, 0x6f, 0x80, 0x6f];
let os_str = OsStr::from_bytes(&source[..]);
assert_eq!(os_str.to_string_lossy(), "fo�o");
}
#[cfg(windows)] {
use std::ffi::OsString;
use std::os::windows::prelude::*;
// Here the values 0x0066 and 0x006f correspond to 'f' and 'o'
// respectively. The value 0xD800 is a lone surrogate half, invalid
// in a UTF-16 sequence.
let source = [0x0066, 0x006f, 0xD800, 0x006f];
let os_string = OsString::from_wide(&source[..]);
let os_str = os_string.as_os_str();
assert_eq!(os_str.to_string_lossy(), "fo�o");
} |
Beta Was this translation helpful? Give feedback.
-
Hello :) About test & documentation where should I add tests, diesel is pretty big and I kind of lost ? Thank you |
Beta Was this translation helpful? Give feedback.
-
Hello,
Is it possible to implement FromSql, ToSql for PathBuf as is it the case for String and also Queryable, Insertable, Identifiable, AsChangeset ?
Right now I have some boilerplate code to do that, for PathBuf and Vec< PathBuf > :
Btw I know I could also use
#[diesel(serialize_as = Vec<u8>, deserialize_as = Vec<u8>)]
but still I need AsChangeset, AsExpression.Thank you
Beta Was this translation helpful? Give feedback.
All reactions