Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/concat/non_standard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub(crate) trait ConcatWith<Clause: PartialEq> {
query: String,
fmts: &fmt::Formatter,
clause: Clause,
items: &Vec<(String, std::sync::Arc<dyn WithQuery>)>,
items: &Vec<(String, std::sync::Arc<dyn WithQuery + Send + Sync>)>,
) -> String {
let fmt::Formatter {
comma,
Expand Down
2 changes: 1 addition & 1 deletion src/delete/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ impl Delete {
/// WHERE id in (select * from deactivated_users)
/// ```
#[cfg(any(feature = "postgresql", feature = "sqlite"))]
pub fn with(mut self, name: &str, query: impl WithQuery + 'static) -> Self {
pub fn with(mut self, name: &str, query: impl WithQuery + 'static + Send + Sync) -> Self {
self._with.push((name.trim().to_string(), std::sync::Arc::new(query)));
self
}
Expand Down
2 changes: 1 addition & 1 deletion src/insert/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ impl Insert {
/// FROM active_users
/// ```
#[cfg(any(feature = "postgresql", feature = "sqlite"))]
pub fn with(mut self, name: &str, query: impl WithQuery + 'static) -> Self {
pub fn with(mut self, name: &str, query: impl WithQuery + 'static + Send + Sync) -> Self {
self._with.push((name.trim().to_string(), std::sync::Arc::new(query)));
self
}
Expand Down
2 changes: 1 addition & 1 deletion src/select/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ impl Select {
/// -- ------------------------------------------------------------------------------
/// ```
#[cfg(any(feature = "postgresql", feature = "sqlite"))]
pub fn with(mut self, name: &str, query: impl WithQuery + 'static) -> Self {
pub fn with(mut self, name: &str, query: impl WithQuery + Send + Sync + 'static) -> Self {
self._with.push((name.trim().to_string(), std::sync::Arc::new(query)));
self
}
Expand Down
8 changes: 4 additions & 4 deletions src/structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ pub struct Delete {
pub(crate) _returning: Vec<String>,

#[cfg(any(feature = "postgresql", feature = "sqlite"))]
pub(crate) _with: Vec<(String, std::sync::Arc<dyn crate::behavior::WithQuery>)>,
pub(crate) _with: Vec<(String, std::sync::Arc<dyn crate::behavior::WithQuery + Send + Sync>)>,
}

/// All available clauses to be used in [Delete::raw_before] and [Delete::raw_after] methods on [Delete] builder
Expand Down Expand Up @@ -381,7 +381,7 @@ pub struct Insert {
pub(crate) _returning: Vec<String>,

#[cfg(any(feature = "postgresql", feature = "sqlite"))]
pub(crate) _with: Vec<(String, std::sync::Arc<dyn crate::behavior::WithQuery>)>,
pub(crate) _with: Vec<(String, std::sync::Arc<dyn crate::behavior::WithQuery + Send + Sync>)>,

#[cfg(not(feature = "sqlite"))]
pub(crate) _insert_into: String,
Expand Down Expand Up @@ -508,7 +508,7 @@ pub struct Select {
pub(crate) _union: Vec<Self>,

#[cfg(any(feature = "postgresql", feature = "sqlite"))]
pub(crate) _with: Vec<(String, Arc<dyn WithQuery>)>,
pub(crate) _with: Vec<(String, Arc<dyn WithQuery + Send + Sync>)>,
}

/// All available clauses to be used in [Select::raw_before] and [Select::raw_after] methods on [Select] builder
Expand Down Expand Up @@ -671,7 +671,7 @@ pub struct Update {
pub(crate) _returning: Vec<String>,

#[cfg(any(feature = "postgresql", feature = "sqlite"))]
pub(crate) _with: Vec<(String, std::sync::Arc<dyn crate::behavior::WithQuery>)>,
pub(crate) _with: Vec<(String, std::sync::Arc<dyn crate::behavior::WithQuery + Send + Sync>)>,

#[cfg(not(feature = "sqlite"))]
pub(crate) _update: String,
Expand Down
2 changes: 1 addition & 1 deletion src/update/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ impl Update {
/// -- ------------------------------------------------------------------------------
/// ```
#[cfg(any(feature = "postgresql", feature = "sqlite"))]
pub fn with(mut self, name: &str, query: impl WithQuery + 'static) -> Self {
pub fn with(mut self, name: &str, query: impl WithQuery + 'static + Send + Sync) -> Self {
self._with.push((name.trim().to_string(), std::sync::Arc::new(query)));
self
}
Expand Down
9 changes: 9 additions & 0 deletions tests/command_delete_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ mod builder_features {

assert_eq!(query, expected_query);
}

/** This test can fail only at compile time
* [More context](https://github.com/belchior/sql_query_builder/pull/53)
*/
#[test]
fn select_builder_should_impl_send_and_sync() {
fn assert_impl_sync_send(_builder: impl Sync + Send) {}
assert_impl_sync_send(sql::Delete::new());
}
}

mod builder_methods {
Expand Down
9 changes: 9 additions & 0 deletions tests/command_insert_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ mod builder_features {

assert_eq!(query, expected_query);
}

/** This test can fail only at compile time
* [More context](https://github.com/belchior/sql_query_builder/pull/53)
*/
#[test]
fn select_builder_should_impl_send_and_sync() {
fn assert_impl_sync_send(_builder: impl Sync + Send) {}
assert_impl_sync_send(sql::Insert::new());
}
}

mod builder_methods {
Expand Down
9 changes: 9 additions & 0 deletions tests/command_select_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,15 @@ mod builder_features {

assert_eq!(query, expected_query);
}

/** This test can fail only at compile time
* [More context](https://github.com/belchior/sql_query_builder/pull/53)
*/
#[test]
fn select_builder_should_impl_send_and_sync() {
fn assert_impl_sync_send(_builder: impl Sync + Send) {}
assert_impl_sync_send(sql::Select::new());
}
}

mod builder_methods {
Expand Down
9 changes: 9 additions & 0 deletions tests/command_update_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,15 @@ mod builder_features {

assert_eq!(query, expected_query);
}

/** This test can fail only at compile time
* [More context](https://github.com/belchior/sql_query_builder/pull/53)
*/
#[test]
fn select_builder_should_impl_send_and_sync() {
fn assert_impl_sync_send(_builder: impl Sync + Send) {}
assert_impl_sync_send(sql::Update::new());
}
}

mod builder_methods {
Expand Down