forked from adwhit/diesel-derive-enum
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
DontImplCloneOnSqlType
attribute.
Because, if schema definitions are separated into other crate, implementing Clone for ExistingType will happen compile error. cf. adwhit#93
- Loading branch information
Showing
3 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use diesel::prelude::*; | ||
|
||
#[cfg(feature = "postgres")] | ||
#[derive(diesel::sql_types::SqlType)] | ||
#[diesel(postgres_type(name = "my_remote_enum"))] | ||
pub struct MyRemoteEnumMapping; | ||
|
||
table! { | ||
use diesel::sql_types::Integer; | ||
use super::MyRemoteEnumMapping; | ||
test_remote { | ||
id -> Integer, | ||
my_enum -> MyRemoteEnumMapping, | ||
} | ||
} | ||
|
||
#[derive(Insertable, Queryable, Identifiable, Debug, Clone, PartialEq)] | ||
#[diesel(table_name = test_remote)] | ||
struct Data { | ||
id: i32, | ||
my_enum: MyRemoteEnum, | ||
} | ||
|
||
#[derive(Debug, PartialEq, Clone, diesel_derive_enum::DbEnum)] | ||
#[ExistingTypePath = "MyRemoteEnumMapping"] | ||
pub enum MyRemoteEnum { | ||
This, | ||
That, | ||
} | ||
|
||
#[test] | ||
fn clone_impl_on_sql_type() { | ||
let x = MyRemoteEnumMapping {}; | ||
let _ = x.clone(); | ||
} |