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
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ matrix:
allow_failures:
- rust: nightly
include:
- rust: nightly-2019-02-26
- rust: nightly-2019-08-01
name: "Compile tests"
env: RUSTFLAGS="--cap-lints=warn"
script:
- (cd diesel_compile_tests && cargo +$TRAVIS_RUST_VERSION test)
- rust: 1.34.0
Expand Down
97 changes: 57 additions & 40 deletions _build/azure-pipelines-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,46 +20,63 @@ jobs:
parameters:
platform: ${{parameters.name}}
rust_version: $(RUSTUP_TOOLCHAIN)
- bash: |
echo $PATH
echo $MYSQLCLIENT_LIB_DIR
displayName: Sanity check path
- bash: |
if [[ "$RUSTUP_TOOLCHAIN" == nightly* ]]; then
- template: failable_step.yml
parameters:
rust_version: $(RUSTUP_TOOLCHAIN)
displayName: Test diesel
bash: |
if [[ "$RUSTUP_TOOLCHAIN" == nightly* ]]; then
(cd diesel && cargo test --no-default-features --features "unstable extras $BACKEND")
else
else
(cd diesel && cargo test --no-default-features --features "extras $BACKEND")
fi &&
(cd diesel && cargo test --no-default-features --features "extras with-deprecated $BACKEND")
displayName: Test diesel
- bash: |
(cd diesel_derives && cargo test --features "diesel/$BACKEND") &&
if [[ "$RUSTUP_TOOLCHAIN" == nightly* ]]; then
fi &&
(cd diesel && cargo test --no-default-features --features "extras with-deprecated $BACKEND")
- template: failable_step.yml
parameters:
rust_version: $(RUSTUP_TOOLCHAIN)
bash: |
(cd diesel_derives && cargo test --features "diesel/$BACKEND") &&
if [[ "$RUSTUP_TOOLCHAIN" == nightly* ]]; then
(cd diesel_derives && cargo test --features "diesel/unstable diesel/$BACKEND")
fi
displayName: Test diesel-derives
- bash: |
(cd "examples/$BACKEND" && ./test_all)
displayName: Test diesel examples
- bash: |
(cd diesel_cli && cargo test --no-default-features --features "$BACKEND")
displayName: Test diesel-cli
- bash: |
(cd diesel_migrations/migrations_internals && cargo test ) &&
(cd diesel_migrations/migrations_macros && cargo test ) &&
(cd diesel_migrations/ && cargo test --features "$BACKEND diesel/$BACKEND" )
displayName: Test diesel-migrations
- bash: |
if [[ "$RUSTUP_TOOLCHAIN" == nightly* ]]; then
(cd diesel_tests && cargo test --no-default-features --features "unstable $BACKEND")
else
(cd diesel_tests && cargo test --no-default-features --features "$BACKEND")
fi
displayName: Run diesel tests
- bash: |
if [[ "$RUSTUP_TOOLCHAIN" == nightly* ]]; then
(cd diesel && cargo doc --no-deps --features "$BACKEND unstable")
else
(cd diesel && cargo doc --no-deps --features "$BACKEND")
fi
displayName: Run rustdoc
fi
displayName: Test diesel-derives
- template: failable_step.yml
parameters:
rust_version: $(RUSTUP_TOOLCHAIN)
bash: |
(cd "examples/$BACKEND" && ./test_all)
displayName: Test diesel examples
- template: failable_step.yml
parameters:
rust_version: $(RUSTUP_TOOLCHAIN)
bash: |
(cd diesel_cli && cargo test --no-default-features --features "$BACKEND")
displayName: Test diesel-cli
- template: failable_step.yml
parameters:
rust_version: $(RUSTUP_TOOLCHAIN)
bash: |
(cd diesel_migrations/migrations_internals && cargo test ) &&
(cd diesel_migrations/migrations_macros && cargo test ) &&
(cd diesel_migrations/ && cargo test --features "$BACKEND diesel/$BACKEND" )
displayName: Test diesel-migrations
- template: failable_step.yml
parameters:
rust_version: $(RUSTUP_TOOLCHAIN)
bash: |
if [[ "$RUSTUP_TOOLCHAIN" == nightly* ]]; then
(cd diesel_tests && cargo test --no-default-features --features "unstable $BACKEND")
else
(cd diesel_tests && cargo test --no-default-features --features "$BACKEND")
fi
displayName: Run diesel tests
- template: failable_step.yml
parameters:
rust_version: $(RUSTUP_TOOLCHAIN)
bash: |
if [[ "$RUSTUP_TOOLCHAIN" == nightly* ]]; then
(cd diesel && cargo doc --no-deps --features "$BACKEND unstable")
else
(cd diesel && cargo doc --no-deps --features "$BACKEND")
fi
displayName: Run rustdoc
29 changes: 29 additions & 0 deletions _build/failable_step.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
parameters:
rust_version: ''

steps:
- bash: |
if [[ "$RUST_VERSION" == nightly* ]]; then
export RUSTFLAGS='--cap-lints=warn'
(${{ parameters.bash }}) 2>&1 | tee log
export EXIT_CODE=${PIPESTATUS[0]}
echo "The exit code is $EXIT_CODE"
if grep -q "warning:" log; then
echo -e "\043#vso[task.logissue type=warning;]${{ parameters.displayName}} contains new warnings"
fi
if [[ $EXIT_CODE -eq 0 ]]; then
true
else
false
fi
else
${{ parameters.bash }}
fi
displayName: ${{ parameters.displayName }}
env:
RUST_VERSION: ${{parameters.rust_version}}
condition: |
or(
startsWith(variables['parameters.rust_version'], 'nightly'),
succeeded()
)
4 changes: 3 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,15 @@ jobs:
- template: _build/install-rust.yml
parameters:
platform: Linux
rust_version: nightly-2019-02-26
rust_version: nightly-2019-08-01
- bash: |
sudo apt-get update &&
sudo apt-get -y install libsqlite3-dev libpq-dev libmysqlclient-dev
displayName: Install build dependencies
- bash: |
(cd diesel_compile_tests && cargo test)
env:
RUSTFLAGS: '--cap-lints=warn'
displayName: Run compile tests

- job: RUSTFMT_AND_CLIPPY
Expand Down
44 changes: 41 additions & 3 deletions diesel/src/expression/operators.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![cfg_attr(rustfmt, rustfmt_skip)] // https://github.com/rust-lang-nursery/rustfmt/issues/2755

#[macro_export]
#[doc(hidden)]
macro_rules! __diesel_operator_body {
Expand Down Expand Up @@ -361,7 +359,6 @@ macro_rules! diesel_prefix_operator {
}
}

infix_operator!(Concat, " || ", ReturnBasedOnArgs);
infix_operator!(And, " AND ");
infix_operator!(Between, " BETWEEN ");
infix_operator!(Escape, " ESCAPE ");
Expand Down Expand Up @@ -409,3 +406,44 @@ where
Eq::new(self.left, &self.right).values()
}
}

#[derive(Debug, Clone, Copy, QueryId, DieselNumericOps, NonAggregate)]
#[doc(hidden)]
pub struct Concat<L, R> {
pub(crate) left: L,
pub(crate) right: R,
}

impl<L, R> Concat<L, R> {
pub fn new(left: L, right: R) -> Self {
Self { left, right }
}
}

impl<L, R, ST> ::expression::Expression for Concat<L, R>
where
L: ::expression::Expression<SqlType = ST>,
R: ::expression::Expression<SqlType = ST>,
{
type SqlType = ST;
}

impl_selectable_expression!(Concat<L, R>);

impl<L, R, DB> ::query_builder::QueryFragment<DB> for Concat<L, R>
where
L: ::query_builder::QueryFragment<DB>,
R: ::query_builder::QueryFragment<DB>,
DB: ::backend::Backend,
{
fn walk_ast(&self, mut out: ::query_builder::AstPass<DB>) -> ::result::QueryResult<()> {
// Those brackets are required because mysql is broken
// https://github.com/diesel-rs/diesel/issues/2133#issuecomment-517432317
out.push_sql("(");
self.left.walk_ast(out.reborrow())?;
out.push_sql(" || ");
self.right.walk_ast(out.reborrow())?;
out.push_sql(")");
Ok(())
}
}
2 changes: 1 addition & 1 deletion diesel_compile_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = ["Sean Griffin <sean@seantheprogrammer.com>"]

[dependencies]
diesel = { version = "1.4.0", default-features = false, features = ["extras", "sqlite", "postgres", "mysql", "unstable"] }
compiletest_rs = "=0.3.17"
compiletest_rs = "=0.3.22"

[replace]
"diesel:1.4.2" = { path = "../diesel" }
Expand Down
2 changes: 1 addition & 1 deletion diesel_compile_tests/rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2019-02-26
nightly-2019-08-01
11 changes: 0 additions & 11 deletions diesel_compile_tests/tests/compile-fail/table_invalid_syntax_3.rs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ error[E0601]: `main` function not found in crate `as_changeset_bad_column_name`

error: aborting due to 7 previous errors

Some errors occurred: E0412, E0425, E0601.
Some errors have detailed explanations: E0412, E0425, E0601.
For more information about an error, try `rustc --explain E0412`.
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ error[E0601]: `main` function not found in crate `as_changeset_bad_column_name_s

error: aborting due to 4 previous errors

Some errors occurred: E0412, E0425, E0601.
Some errors have detailed explanations: E0412, E0425, E0601.
For more information about an error, try `rustc --explain E0412`.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error: Expected `bar` found `bar = "baz"`
12 | #[primary_key(id, bar = "baz", qux(id))]
| ^^^

error: Expected `qux` found `qux ( id )`
error: Expected `qux` found `qux (id)`
--> $DIR/as_changeset_bad_primary_key_syntax.rs:12:32
|
12 | #[primary_key(id, bar = "baz", qux(id))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ error[E0601]: `main` function not found in crate `as_changeset_missing_column_na

error: aborting due to 7 previous errors

Some errors occurred: E0412, E0425, E0601.
Some errors have detailed explanations: E0412, E0425, E0601.
For more information about an error, try `rustc --explain E0412`.
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ error[E0277]: the trait bound `(): diesel::query_builder::AsChangeset` is not sa

error: aborting due to 3 previous errors

Some errors occurred: E0277, E0601.
Some errors have detailed explanations: E0277, E0601.
For more information about an error, try `rustc --explain E0277`.
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ error[E0425]: cannot find value `bar_id` in module `foo`

error: aborting due to 8 previous errors

Some errors occurred: E0412, E0425.
Some errors have detailed explanations: E0412, E0425.
For more information about an error, try `rustc --explain E0412`.
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ error[E0425]: cannot find value `name` in module `users`

error: aborting due to 6 previous errors

Some errors occurred: E0412, E0425, E0433.
Some errors have detailed explanations: E0412, E0425, E0433.
For more information about an error, try `rustc --explain E0412`.