Skip to content

Commit 9ed7de2

Browse files
authored
Merge pull request #4236 from xmtp/insipx/sqlite-replace-ignore-pub
Makes `InsertOrIgnore`/`Replace` + items in `combination_clause` public for 3rd party backends
2 parents 2a9fec9 + a186318 commit 9ed7de2

File tree

60 files changed

+617
-970
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+617
-970
lines changed

diesel/src/query_builder/combination_clause.rs

+14-6
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ impl<Combinator, Rule, Source, Rhs> CombinationClause<Combinator, Rule, Source,
5757
CombinationClause {
5858
combinator,
5959
duplicate_rule,
60-
source: ParenthesisWrapper(source),
61-
rhs: ParenthesisWrapper(rhs),
60+
source: ParenthesisWrapper { inner: source },
61+
rhs: ParenthesisWrapper { inner: rhs },
6262
order: NoOrderClause,
6363
limit_offset: LimitOffsetClause {
6464
limit_clause: NoLimitClause,
@@ -357,7 +357,15 @@ pub trait SupportsCombinationClause<Combinator, Rule> {}
357357

358358
#[derive(Debug, Copy, Clone, QueryId)]
359359
/// Wrapper used to wrap rhs sql in parenthesis when supported by backend
360-
pub struct ParenthesisWrapper<T>(T);
360+
#[diesel_derives::__diesel_public_if(
361+
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes",
362+
public_fields(inner)
363+
)]
364+
pub struct ParenthesisWrapper<T> {
365+
/// the inner parenthesis definition
366+
#[allow(dead_code)]
367+
inner: T,
368+
}
361369

362370
#[cfg(feature = "postgres_backend")]
363371
mod postgres {
@@ -367,7 +375,7 @@ mod postgres {
367375
impl<T: QueryFragment<Pg>> QueryFragment<Pg> for ParenthesisWrapper<T> {
368376
fn walk_ast<'b>(&'b self, mut out: AstPass<'_, 'b, Pg>) -> QueryResult<()> {
369377
out.push_sql("(");
370-
self.0.walk_ast(out.reborrow())?;
378+
self.inner.walk_ast(out.reborrow())?;
371379
out.push_sql(")");
372380
Ok(())
373381
}
@@ -389,7 +397,7 @@ mod mysql {
389397
impl<T: QueryFragment<Mysql>> QueryFragment<Mysql> for ParenthesisWrapper<T> {
390398
fn walk_ast<'b>(&'b self, mut out: AstPass<'_, 'b, Mysql>) -> QueryResult<()> {
391399
out.push_sql("(");
392-
self.0.walk_ast(out.reborrow())?;
400+
self.inner.walk_ast(out.reborrow())?;
393401
out.push_sql(")");
394402
Ok(())
395403
}
@@ -410,7 +418,7 @@ mod sqlite {
410418
// we can emulate this by construct a fake outer
411419
// SELECT * FROM (inner_query) statement
412420
out.push_sql("SELECT * FROM (");
413-
self.0.walk_ast(out.reborrow())?;
421+
self.inner.walk_ast(out.reborrow())?;
414422
out.push_sql(")");
415423
Ok(())
416424
}

diesel/src/query_builder/insert_statement/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ mod insert_from_select;
55
pub(crate) use self::batch_insert::BatchInsert;
66
pub(crate) use self::column_list::ColumnList;
77
pub(crate) use self::insert_from_select::InsertFromSelect;
8+
#[diesel_derives::__diesel_public_if(
9+
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"
10+
)]
811
pub(crate) use self::private::{Insert, InsertOrIgnore, Replace};
912

1013
use super::returning_clause::*;

diesel/src/query_builder/mod.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ pub use self::update_statement::target::{IntoUpdateTarget, UpdateTarget};
6464
#[doc(inline)]
6565
pub use self::update_statement::{BoxedUpdateStatement, UpdateStatement};
6666

67+
#[cfg(feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes")]
68+
pub use self::combination_clause::{
69+
All, Distinct, Except, Intersect, ParenthesisWrapper, SupportsCombinationClause, Union,
70+
};
6771
#[cfg(feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes")]
6872
pub use self::limit_clause::{LimitClause, NoLimitClause};
6973
#[cfg(feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes")]
@@ -83,7 +87,7 @@ pub(crate) use self::insert_statement::{UndecoratedInsertRecord, ValuesClause};
8387

8488
#[cfg(feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes")]
8589
#[doc(inline)]
86-
pub use self::insert_statement::DefaultValues;
90+
pub use self::insert_statement::{DefaultValues, InsertOrIgnore, Replace};
8791

8892
#[cfg(feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes")]
8993
#[doc(inline)]

0 commit comments

Comments
 (0)