Skip to content

Commit f445bc1

Browse files
authored
Merge pull request diesel-rs#2827 from weiznich/prepared_statements_for_certain_insert_variants
Various insert improvments
2 parents 77fe243 + d7f7da6 commit f445bc1

52 files changed

Lines changed: 1095 additions & 472 deletions

File tree

Some content is hidden

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

.github/workflows/benches.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ jobs:
1010
if: github.event.label.name == 'run-benchmarks'
1111
runs-on: ubuntu-latest
1212
strategy:
13+
fail-fast: false
1314
matrix:
1415
backend: ["postgres", "sqlite", "mysql"]
1516
steps:

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ jobs:
325325
- uses: actions/checkout@v2
326326
- uses: actions-rs/toolchain@v1
327327
with:
328-
toolchain: 1.48.0
328+
toolchain: 1.51.0
329329
profile: minimal
330330
components: clippy, rustfmt
331331
override: true
@@ -389,13 +389,13 @@ jobs:
389389
args: --manifest-path diesel_cli/Cargo.toml --no-default-features --features "sqlite-bundled"
390390

391391
minimal_rust_version:
392-
name: Check Minimal supported rust version (1.48.0)
392+
name: Check Minimal supported rust version (1.51.0)
393393
runs-on: ubuntu-latest
394394
steps:
395395
- uses: actions/checkout@v2
396396
- uses: actions-rs/toolchain@v1
397397
with:
398-
toolchain: 1.48.0
398+
toolchain: 1.51.0
399399
profile: minimal
400400
override: true
401401
- name: Cache cargo registry
@@ -413,7 +413,7 @@ jobs:
413413
run: |
414414
RUSTC_BOOTSTRAP=1 cargo update -Z minimal-versions
415415
416-
- name: Check building with rust 1.48.0
416+
- name: Check building with rust 1.51.0
417417
uses: actions-rs/cargo@v1
418418
with:
419419
command: check

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ for Rust libraries in [RFC #1105](https://github.com/rust-lang/rfcs/blob/master/
6666

6767
* Diesel CLI will now generate SQL type definitions for SQL types that are not supported by diesel out of the box. It's possible to disable this behavior via the `generate_missing_sql_type_definitions` config option.
6868

69+
* Added an option to `#[derive(Insertable)]` that let you insert `NULL` values instead of `DEFAULT` values for `Option<T>`
70+
6971
### Removed
7072

7173
* All previously deprecated items have been removed.
@@ -97,7 +99,7 @@ for Rust libraries in [RFC #1105](https://github.com/rust-lang/rfcs/blob/master/
9799
you are implementing `HasSqlType` for `Mysql` manually, you may need to adjust
98100
your implementation to fully use the new unsigned variants in `MysqlType`
99101

100-
* The minimal officially supported rustc version is now 1.48.0
102+
* The minimal officially supported rustc version is now 1.51.0
101103

102104
* The `RawValue` types for the `Mysql` and `Postgresql` backend where changed
103105
from `[u8]` to distinct opaque types. If you used the concrete `RawValue` type

diesel/src/backend.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ pub trait HasRawValue<'a> {
6161
}
6262

6363
/// A trait indicating that the provided raw value uses a binary representation internally
64+
// That's a false positive, `HasRawValue<'a>` is essentially
65+
// a reference wrapper
66+
#[allow(clippy::wrong_self_convention)]
6467
pub trait BinaryRawValue<'a>: HasRawValue<'a> {
6568
/// Get the underlying binary representation of the raw value
6669
fn as_bytes(value: Self::RawValue) -> &'a [u8];

diesel/src/expression/array_comparison.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ impl_selectable_expression!(NotIn<T, U>);
9696
pub trait AsInExpression<T: SqlType + TypedExpressionType> {
9797
type InExpression: MaybeEmpty + Expression<SqlType = T>;
9898

99+
#[allow(clippy::wrong_self_convention)]
100+
// That's a public api, we cannot just change it to
101+
// appease clippy
99102
fn as_in_expression(self) -> Self::InExpression;
100103
}
101104

diesel/src/expression/functions/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ macro_rules! no_arg_sql_function_body_except_to_sql {
1111
#[allow(non_camel_case_types)]
1212
#[doc=$docs]
1313
#[derive(
14-
Debug,
15-
Clone,
16-
Copy,
17-
$crate::query_builder::QueryId,
18-
$crate::expression::ValidGrouping
14+
Debug, Clone, Copy, $crate::query_builder::QueryId, $crate::expression::ValidGrouping,
1915
)]
2016
pub struct $type_name;
2117

diesel/src/expression/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ where
205205
type Expression: Expression<SqlType = T>;
206206

207207
/// Perform the conversion
208+
#[allow(clippy::wrong_self_convention)]
209+
// That's public API we cannot change it to appease clippy
208210
fn as_expression(self) -> Self::Expression;
209211
}
210212

@@ -840,5 +842,8 @@ pub trait AsExpressionList<ST> {
840842
type Expression;
841843

842844
/// Perform the conversion
845+
// That's public API, we cannot change
846+
// that to appease clippy
847+
#[allow(clippy::wrong_self_convention)]
843848
fn as_expression_list(self) -> Self::Expression;
844849
}

diesel/src/expression/operators.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ where
539539
type Values = ValuesClause<ColumnInsertValue<T, U>, T::Table>;
540540

541541
fn values(self) -> Self::Values {
542-
ValuesClause::new(ColumnInsertValue::Expression(self.left, self.right))
542+
ValuesClause::new(ColumnInsertValue::new(self.left, self.right))
543543
}
544544
}
545545

diesel/src/expression_methods/global_expression_methods.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ pub trait ExpressionMethods: Expression + Sized {
159159
/// assert_eq!("spider", data);
160160
/// # Ok(())
161161
/// # }
162+
// This method is part of the public API,
163+
// so we cannot just change the name to appease clippy
164+
// (Otherwise it's also named after the `IS NULL` sql expression
165+
// so that name is really fine)
166+
#[allow(clippy::wrong_self_convention)]
162167
fn is_null(self) -> dsl::IsNull<Self> {
163168
Grouped(IsNull::new(self))
164169
}
@@ -185,6 +190,11 @@ pub trait ExpressionMethods: Expression + Sized {
185190
/// assert_eq!("dog", data);
186191
/// # Ok(())
187192
/// # }
193+
// This method is part of the public API,
194+
// so we cannot just change the name to appease clippy
195+
// (Otherwise it's also named after the `IS NOT NULL` sql expression
196+
// so that name is really fine)
197+
#[allow(clippy::wrong_self_convention)]
188198
fn is_not_null(self) -> dsl::IsNotNull<Self> {
189199
Grouped(IsNotNull::new(self))
190200
}

0 commit comments

Comments
 (0)