Skip to content
Closed
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
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ matrix:
allow_failures:
- rust: nightly
include:
- rust: nightly-2019-08-01
- rust: nightly-2019-12-29
name: "Compile tests"
env: RUSTFLAGS="--cap-lints=warn"
script:
- (cd diesel_compile_tests && cargo test)
- rust: 1.37.0
- rust: 1.40.0
name: "Rustfmt && Clippy"
script:
- rustup component add rustfmt clippy
Expand All @@ -66,8 +66,8 @@ matrix:
- SQLITE_DATABASE_URL=/tmp/test.db
script:
- (cd diesel_cli && cargo test --no-default-features --features "sqlite-bundled")
- rust: 1.37.0
name: "Minimal supported rust version == 1.37.0"
- rust: 1.40.0
name: "Minimal supported rust version == 1.40.0"
script:
- cargo check --all

Expand Down
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ for Rust libraries in [RFC #1105](https://github.com/rust-lang/rfcs/blob/master/
* The `MacAddr` SQL type can now be used without enabling the `network-address`
feature.

* A unstable pure rust postgresql connection implementation (`PostgresConnection`) was added behind the `unstable_pure_rust_postgres` feature flag. It is based on the `postgres` crate

### Removed

* All previously deprecated items have been removed.
Expand All @@ -47,7 +49,7 @@ for Rust libraries in [RFC #1105](https://github.com/rust-lang/rfcs/blob/master/
`Mysql::TypeMetadata`, you will need to take the new struct
`MysqlTypeMetadata` instead.

* The minimal officially supported rustc version is now 1.36.0
* The minimal officially supported rustc version is now 1.37.0

* The `RawValue` types for the `Mysql` and `Postgresql` backend where changed
from `[u8]` to distinct opaque types. If you used the concrete `RawValue` type
Expand Down
4 changes: 2 additions & 2 deletions _build/install-rust.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
steps:
# Linux and Windows
- bash: |
rustup install $RUSTUP_TOOLCHAIN
rustup install --force $RUSTUP_TOOLCHAIN
env:
RUSTUP_TOOLCHAIN: ${{parameters.rust_version}}
displayName: Install rust
condition: not(eq(variables['Agent.OS'], 'Darwin'))
# Macos
- script: |
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $RUSTUP_TOOLCHAIN
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $RUSTUP_TOOLCHAIN --profile minimal
echo "##vso[task.setvariable variable=PATH;]$PATH:$HOME/.cargo/bin"
env:
RUSTUP_TOOLCHAIN: ${{parameters.rust_version}}
Expand Down
26 changes: 22 additions & 4 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ jobs:
- template: _build/install-rust.yml
parameters:
platform: Linux
rust_version: nightly-2019-08-01
rust_version: nightly-2019-12-29
- bash: |
sudo apt-get update &&
sudo apt-get -y install libsqlite3-dev libpq-dev libmysqlclient-dev
Expand All @@ -197,7 +197,7 @@ jobs:
- template: _build/install-rust.yml
parameters:
platform: Linux
rust_version: 1.36.0
rust_version: 1.40.0
- bash: |
sudo apt-get update &&
sudo apt-get -y install libsqlite3-dev libpq-dev libmysqlclient-dev
Expand Down Expand Up @@ -241,11 +241,29 @@ jobs:
- template: _build/install-rust.yml
parameters:
platform: Linux
rust_version: 1.36.0
rust_version: 1.37.0
- bash: |
sudo apt-get update &&
sudo apt-get -y install libsqlite3-dev libpq-dev libmysqlclient-dev
displayName: Install build dependencies
- bash: |
cargo check --all
displayName: Check building with rust 1.36.0
displayName: Check building with rust 1.37.0

- job: PURE_RUST_POSTGRES
displayName: Test pure rust postgres connection implementation
pool:
vmImage: ubuntu-16.04
variables:
PG_DATABASE_URL: postgres://postgres@localhost/
steps:
- template: _build/install-rust.yml
parameters:
platform: Linux
rust_version: 1.40.0
- bash: |
(cd diesel && cargo test --no-default-features --features "extras unstable_pure_rust_postgres")
displayName: Test diesel
- bash: |
(cd diesel_tests && cargo test --no-default-features --features "unstable_pure_rust_postgres")
displayName: Run diesel tests
5 changes: 4 additions & 1 deletion diesel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ libc = { version = "0.2.0", optional = true }
libsqlite3-sys = { version = ">=0.8.0, <0.17.0", optional = true, features = ["min_sqlite_version_3_7_16"] }
mysqlclient-sys = { version = ">=0.1.0, <0.3.0", optional = true }
pq-sys = { version = ">=0.3.0, <0.5.0", optional = true }
postgresql = {version = "0.17", optional = true, package = "postgres" }
bytes = {version = "0.5", optional = true}
quickcheck = { version = "0.4", optional = true }
serde_json = { version = ">=0.8.0, <2.0", optional = true }
time = { version = "0.1", optional = true }
Expand All @@ -41,7 +43,7 @@ dotenv = ">=0.8, <0.11"
quickcheck = "0.4"

[features]
default = ["with-deprecated", "32-column-tables"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to remove 32-column-tables from default? It bit me in the behind while porting to the new system as the error message when lacking it isn't really that great.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that's only a left over artefact from local development. I tend to disable the 32-column-tables feature, because this reduces the time needed to compile of diesel quite significantly.

(But yes, this should be fixed before merging)

default = ["postgres", "unstable_pure_rust_postgres"]
extras = ["chrono", "serde_json", "uuidv07", "deprecated-time", "network-address", "numeric", "r2d2"]
unstable = ["diesel_derives/nightly"]
large-tables = ["32-column-tables"]
Expand All @@ -50,6 +52,7 @@ huge-tables = ["64-column-tables"]
64-column-tables = ["32-column-tables"]
128-column-tables = ["64-column-tables"]
postgres = ["pq-sys", "bitflags", "diesel_derives/postgres"]
unstable_pure_rust_postgres = ["bitflags", "diesel_derives/postgres", "postgresql", "bytes"]
sqlite = ["libsqlite3-sys", "diesel_derives/sqlite"]
mysql = ["mysqlclient-sys", "url", "percent-encoding", "diesel_derives/mysql"]
with-deprecated = []
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/data_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
//! confusing (such as date and time types). This module will re-export
//! all backend specific data structures when compiled against that
//! backend.
#[cfg(feature = "postgres")]
#[cfg(any(feature = "postgres", feature = "unstable_pure_rust_postgres"))]
pub use crate::pg::data_types::*;
26 changes: 16 additions & 10 deletions diesel/src/doctest_setup.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
extern crate dotenv;
#[macro_use] extern crate cfg_if;
#[macro_use]
extern crate cfg_if;

use diesel::prelude::*;
use self::dotenv::dotenv;
use diesel::prelude::*;

cfg_if! {
if #[cfg(feature = "postgres")] {
if #[cfg(any(feature = "postgres", feature = "unstable_pure_rust_postgres"))] {
#[allow(dead_code)]
type DB = diesel::pg::Pg;

fn connection_no_transaction() -> PgConnection {
#[cfg(feature = "postgres")]
type DbConnection = PgConnection;

#[cfg(feature = "unstable_pure_rust_postgres")]
type DbConnection = PostgresConnection;

fn connection_no_transaction() -> DbConnection {
let connection_url = database_url_from_env("PG_DATABASE_URL");
PgConnection::establish(&connection_url).unwrap()
DbConnection::establish(&connection_url).unwrap()
}

fn connection_no_data() -> PgConnection {
fn connection_no_data() -> DbConnection {
let connection = connection_no_transaction();
connection.begin_test_transaction().unwrap();
connection.execute("DROP TABLE IF EXISTS users CASCADE").unwrap();
Expand All @@ -26,7 +33,7 @@ cfg_if! {
}

#[allow(dead_code)]
fn establish_connection() -> PgConnection {
fn establish_connection() -> DbConnection {
let connection = connection_no_data();

connection.execute("CREATE TABLE users (
Expand Down Expand Up @@ -104,7 +111,7 @@ cfg_if! {
(1, 'My first post'),
(1, 'About Rust'),
(2, 'My first post too')").unwrap();

connection.execute("CREATE TABLE comments (
id INTEGER PRIMARY KEY AUTOINCREMENT,
post_id INTEGER NOT NULL,
Expand Down Expand Up @@ -161,7 +168,7 @@ cfg_if! {
(1, 'My first post'),
(1, 'About Rust'),
(2, 'My first post too')").unwrap();

connection.execute("CREATE TABLE comments (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
post_id INTEGER NOT NULL,
Expand Down Expand Up @@ -195,7 +202,6 @@ fn database_url_from_env(backend_specific_env_var: &str) -> String {
.expect("DATABASE_URL must be set in order to run tests")
}


mod schema {
table! {
animals {
Expand Down
4 changes: 2 additions & 2 deletions diesel/src/expression/functions/date_and_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl AsExpression<Nullable<Timestamp>> for now {
}
}

#[cfg(feature = "postgres")]
#[cfg(any(feature = "postgres", feature = "unstable_pure_rust_postgres"))]
impl AsExpression<Timestamptz> for now {
type Expression = Coerce<now, Timestamptz>;

Expand All @@ -63,7 +63,7 @@ impl AsExpression<Timestamptz> for now {
}
}

#[cfg(feature = "postgres")]
#[cfg(any(feature = "postgres", feature = "unstable_pure_rust_postgres"))]
impl AsExpression<Nullable<Timestamptz>> for now {
type Expression = Coerce<now, Nullable<Timestamptz>>;

Expand Down
2 changes: 1 addition & 1 deletion diesel/src/expression/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub mod dsl {
#[doc(inline)]
pub use super::sql_literal::sql;

#[cfg(feature = "postgres")]
#[cfg(any(feature = "postgres", feature = "unstable_pure_rust_postgres"))]
pub use crate::pg::expression::dsl::*;

/// The return type of [`count(expr)`](../dsl/fn.count.html)
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/expression_methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ pub use self::global_expression_methods::{ExpressionMethods, NullableExpressionM
#[doc(inline)]
pub use self::text_expression_methods::TextExpressionMethods;

#[cfg(feature = "postgres")]
#[cfg(any(feature = "postgres", feature = "unstable_pure_rust_postgres"))]
#[doc(inline)]
pub use crate::pg::expression::expression_methods::*;
9 changes: 4 additions & 5 deletions diesel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@
clippy::used_underscore_binding
)]

#[cfg(feature = "postgres")]
#[macro_use]
extern crate bitflags;
extern crate byteorder;
#[macro_use]
extern crate diesel_derives;
Expand Down Expand Up @@ -168,7 +165,7 @@ pub mod row;

#[cfg(feature = "mysql")]
pub mod mysql;
#[cfg(feature = "postgres")]
#[cfg(any(feature = "postgres", feature = "unstable_pure_rust_postgres"))]
pub mod pg;
#[cfg(feature = "sqlite")]
pub mod sqlite;
Expand Down Expand Up @@ -280,7 +277,7 @@ pub mod helper_types {
pub type Distinct<Source> = <Source as DistinctDsl>::Output;

/// Represents the return type of `.distinct_on(expr)`
#[cfg(feature = "postgres")]
#[cfg(any(feature = "postgres", feature = "unstable_pure_rust_postgres"))]
pub type DistinctOn<Source, Expr> = <Source as DistinctOnDsl<Expr>>::Output;

/// Represents the return type of `.single_value()`
Expand Down Expand Up @@ -316,6 +313,8 @@ pub mod prelude {
pub use crate::mysql::MysqlConnection;
#[cfg(feature = "postgres")]
pub use crate::pg::PgConnection;
#[cfg(feature = "unstable_pure_rust_postgres")]
pub use crate::pg::PostgresConnection;
#[cfg(feature = "sqlite")]
pub use crate::sqlite::SqliteConnection;
}
Expand Down
6 changes: 3 additions & 3 deletions diesel/src/macros/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,7 @@ mod tests {
}

#[test]
#[cfg(feature = "postgres")]
#[cfg(any(feature = "postgres", feature = "unstable_pure_rust_postgres"))]
fn table_with_custom_schema() {
use crate::pg::Pg;
let expected_sql = r#"SELECT "foo"."bars"."baz" FROM "foo"."bars" -- binds: []"#;
Expand Down Expand Up @@ -1158,7 +1158,7 @@ mod tests {
);

#[test]
#[cfg(feature = "postgres")]
#[cfg(any(feature = "postgres", feature = "unstable_pure_rust_postgres"))]
fn table_with_column_renaming_postgres() {
use crate::pg::Pg;
let expected_sql =
Expand Down Expand Up @@ -1205,7 +1205,7 @@ mod tests {
);

#[test]
#[cfg(feature = "postgres")]
#[cfg(any(feature = "postgres", feature = "unstable_pure_rust_postgres"))]
fn table_renaming_postgres() {
use crate::pg::Pg;
let expected_sql = r#"SELECT "mod"."id" FROM "mod" -- binds: []"#;
Expand Down
8 changes: 8 additions & 0 deletions diesel/src/migration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ impl MigrationConnection for crate::pg::PgConnection {
}
}

#[cfg(feature = "unstable_pure_rust_postgres")]
impl MigrationConnection for crate::pg::PostgresConnection {
fn setup(&self) -> QueryResult<usize> {
use crate::RunQueryDsl;
crate::sql_query(CREATE_MIGRATIONS_TABLE).execute(self)
}
}

#[cfg(feature = "mysql")]
impl MigrationConnection for crate::mysql::MysqlConnection {
fn setup(&self) -> QueryResult<usize> {
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/pg/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl PgConnection {
/// .run(|| Ok(()))
/// # }
/// ```
pub fn build_transaction(&self) -> TransactionBuilder {
pub fn build_transaction(&self) -> TransactionBuilder<Self> {
TransactionBuilder::new(self)
}

Expand Down
9 changes: 7 additions & 2 deletions diesel/src/pg/expression/extensions/interval_dsl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,19 @@ mod tests {
use crate::prelude::*;
use crate::{select, sql_types};

#[cfg(feature = "postgres")]
type DbConnection = PgConnection;
#[cfg(feature = "unstable_pure_rust_postgres")]
type DbConnection = PostgresConnection;

thread_local! {
static CONN: PgConnection = {
static CONN: DbConnection = {
dotenv().ok();

let connection_url = ::std::env::var("PG_DATABASE_URL")
.or_else(|_| ::std::env::var("DATABASE_URL"))
.expect("DATABASE_URL must be set in order to run tests");
PgConnection::establish(&connection_url).unwrap()
DbConnection::establish(&connection_url).unwrap()
}
}

Expand Down
Loading