Skip to content

Commit

Permalink
Merge pull request #4063 from sugar700/allow-type-name-conflicting-wi…
Browse files Browse the repository at this point in the history
…th-trait-in-queryable

Allow Field and Row types with Queryable derive
  • Loading branch information
weiznich committed Jun 12, 2024
1 parent 5c870f7 commit 1062c27
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion diesel_derives/src/queryable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub fn derive(item: DeriveInput) -> Result<TokenStream> {

Ok(wrap_in_dummy_mod(quote! {
use diesel::deserialize::{self, FromStaticSqlRow, Queryable};
use diesel::row::{Row, Field};
use diesel::row::{Row as _, Field as _};
use std::convert::TryInto;

impl #impl_generics Queryable<(#(#sql_type,)*), __DB> for #struct_name #ty_generics
Expand Down
13 changes: 13 additions & 0 deletions diesel_derives/tests/queryable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,16 @@ fn multiple_tables() {
data
);
}

#[test]
fn name_conflict() {
type Field = i32;
type Record = i32;

#[derive(Debug, Clone, PartialEq, Eq, Queryable)]
struct MyStruct(Field, Record);

let conn = &mut connection();
let data = select(sql::<(Integer, Integer)>("1, 2")).get_result(conn);
assert_eq!(Ok(MyStruct(1, 2)), data);
}

0 comments on commit 1062c27

Please sign in to comment.