Skip to content

Commit

Permalink
Add test and support for update(...) to auto_type
Browse files Browse the repository at this point in the history
  • Loading branch information
Ten0 committed Sep 20, 2024
1 parent b8bbc47 commit 692028c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions diesel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,11 @@ pub mod helper_types {
#[allow(non_camel_case_types)] // required for `#[auto_type]`
pub type insert_into<T> = crate::query_builder::IncompleteInsertStatement<T>;

/// Represents the return type of [`diesel::update`]
#[allow(non_camel_case_types)] // required for `#[auto_type]`
pub type update<T> =
UpdateStatement<<T as HasTable>::Table, <T as IntoUpdateTarget>::WhereClause>;

/// Represents the return type of [`diesel::insert_or_ignore_into`]
#[allow(non_camel_case_types)] // required for `#[auto_type]`
pub type insert_or_ignore_into<T> = crate::query_builder::IncompleteInsertOrIgnoreStatement<T>;
Expand Down
8 changes: 8 additions & 0 deletions diesel_derives/tests/auto_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,14 @@ fn delete_returning() -> _ {
delete(users::table).returning(users::id)
}

#[auto_type]
fn pg_interval() -> _ {
update(pg_extras::table).set(pg_extras::timestamp.eq(pg_extras::timestamp + {
let v: diesel::data_types::PgInterval = 1.year();
v
}))
}

// #[auto_type]
// fn test_sql_fragment() -> _ {
// sql("foo")
Expand Down

0 comments on commit 692028c

Please sign in to comment.