Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare a 2.2.7 patch release #4459

Merged
merged 16 commits into from
Jan 31, 2025
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
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: "cargo"
directory: "/"
allow:
dependency-type: "direct"
schedule:
interval: "weekly"
reviewers:
- "diesel/reviewer"
versioning-strategy: "widen"
118 changes: 65 additions & 53 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,20 @@ concurrency:
jobs:
check_and_test:
name: Check
needs: [sqlite_bundled, rustfmt_and_clippy, postgres_bundled, mysql_bundled, typos]
needs:
[
sqlite_bundled,
rustfmt_and_clippy,
postgres_bundled,
mysql_bundled,
typos,
]
strategy:
fail-fast: false
matrix:
rust: ["stable", "beta", "nightly"]
backend: ["postgres", "sqlite", "mysql"]
os: [ubuntu-latest, macos-13, macos-14, windows-2019]
os: [ubuntu-latest, macos-13, macos-15, windows-2025]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
Expand All @@ -36,7 +43,7 @@ jobs:
- name: Cache cargo registry
uses: Swatinem/rust-cache@v2
with:
key: ${{ runner.os }}-${{ matrix.backend }}-cargo-${{ hashFiles('**/Cargo.toml') }}
key: ${{ matrix.os }}-${{ matrix.backend }}-cargo-${{ hashFiles('**/Cargo.toml') }}

- name: Set environment variables
shell: bash
Expand All @@ -63,7 +70,6 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y libpq-dev postgresql
echo "host all all 127.0.0.1/32 md5" > sudo tee -a /etc/postgresql/10/main/pg_hba.conf
sudo service postgresql restart && sleep 3
sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';"
sudo service postgresql restart && sleep 3
Expand All @@ -73,6 +79,10 @@ jobs:
- name: Install sqlite (Linux)
if: runner.os == 'Linux' && matrix.backend == 'sqlite'
run: |
# ubuntu's libsqlite3 version is currently broken
# https://bugs.launchpad.net/ubuntu/+source/sqlite3/+bug/2087772
# That results in segfaults in our tests :(
sudo apt-get remove libsqlite3-dev
curl -fsS --retry 3 -o sqlite-autoconf-3400100.tar.gz https://www.sqlite.org/2022/sqlite-autoconf-3400100.tar.gz
tar zxf sqlite-autoconf-3400100.tar.gz
cd sqlite-autoconf-3400100
Expand Down Expand Up @@ -110,15 +120,13 @@ jobs:
if: runner.os == 'Linux' && matrix.backend == 'mysql'
run: |
sudo systemctl start mysql.service
sudo apt-get update
sudo apt-get -y install libmysqlclient-dev
mysql -e "create database diesel_test; create database diesel_unit_test; grant all on \`diesel_%\`.* to 'root'@'localhost';" -uroot -proot
echo "MYSQL_DATABASE_URL=mysql://root:root@localhost/diesel_test" >> $GITHUB_ENV
echo "MYSQL_EXAMPLE_DATABASE_URL=mysql://root:root@localhost/diesel_example" >> $GITHUB_ENV
echo "MYSQL_UNIT_TEST_DATABASE_URL=mysql://root:root@localhost/diesel_unit_test" >> $GITHUB_ENV
echo "MYSQL_DATABASE_URL=mysql://root:root@127.0.0.1/diesel_test" >> $GITHUB_ENV
echo "MYSQL_EXAMPLE_DATABASE_URL=mysql://root:root@127.0.0.1/diesel_example" >> $GITHUB_ENV
echo "MYSQL_UNIT_TEST_DATABASE_URL=mysql://root:root@127.0.0.1/diesel_unit_test" >> $GITHUB_ENV

- name: Install postgres (MacOS)
if: matrix.os == 'macos-13' && matrix.backend == 'postgres'
if: matrix.os == 'macos-13' || matrix.os == 'macos-15' && matrix.backend == 'postgres'
run: |
brew install postgresql@14
brew services start postgresql@14
Expand All @@ -140,46 +148,44 @@ jobs:
- name: Install sqlite (MacOS)
if: runner.os == 'macOS' && matrix.backend == 'sqlite'
run: |
brew install sqlite
# otherwise brew install fails
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 brew install sqlite
echo "SQLITE_DATABASE_URL=/tmp/test.db" >> $GITHUB_ENV

- name: Install mysql (MacOS)
if: matrix.os == 'macos-13' && matrix.backend == 'mysql'
run: |
brew install [email protected]
/usr/local/opt/[email protected]/bin/mysql_install_db
/usr/local/opt/[email protected]/bin/mysql.server start
brew install [email protected]
/usr/local/opt/[email protected]/bin/mysql.server start
sleep 3
/usr/local/opt/[email protected]/bin/mysql -e "create database diesel_test; create database diesel_unit_test; grant all on \`diesel_%\`.* to 'runner'@'localhost';" -urunner
echo "MYSQL_DATABASE_URL=mysql://runner@localhost/diesel_test" >> $GITHUB_ENV
echo "MYSQL_EXAMPLE_DATABASE_URL=mysql://runner@localhost/diesel_example" >> $GITHUB_ENV
echo "MYSQL_UNIT_TEST_DATABASE_URL=mysql://runner@localhost/diesel_unit_test" >> $GITHUB_ENV
echo "MYSQLCLIENT_LIB_DIR=/usr/local/opt/[email protected]/lib" >> $GITHUB_ENV
echo "MYSQLCLIENT_VERSION=10.5" >> $GITHUB_ENV

/usr/local/opt/[email protected]/bin/mysql -e "create database diesel_test; create database diesel_unit_test; grant all on \`diesel_%\`.* to 'root'@'localhost';" -uroot
echo "MYSQL_DATABASE_URL=mysql://[email protected]/diesel_test" >> $GITHUB_ENV
echo "MYSQL_EXAMPLE_DATABASE_URL=mysql://[email protected]/diesel_example" >> $GITHUB_ENV
echo "MYSQL_UNIT_TEST_DATABASE_URL=mysql://[email protected]/diesel_unit_test" >> $GITHUB_ENV
echo "MYSQLCLIENT_LIB_DIR=/usr/local/opt/[email protected]/lib" >> $GITHUB_ENV
echo "MYSQLCLIENT_VERSION=8.4" >> $GITHUB_ENV

- name: Install mysql (MacOS M1)
if: matrix.os == 'macos-14' && matrix.backend == 'mysql'
if: matrix.os == 'macos-15' && matrix.backend == 'mysql'
run: |
brew install [email protected]
ls /opt/homebrew/opt/[email protected]
/opt/homebrew/opt/[email protected]/bin/mysql_install_db
/opt/homebrew/opt/[email protected]/bin/mysql.server start
brew install [email protected]
ls /opt/homebrew/opt/[email protected]
/opt/homebrew/opt/[email protected]/bin/mysql.server start
sleep 3
/opt/homebrew/opt/[email protected]/bin/mysql -e "create database diesel_test; create database diesel_unit_test; grant all on \`diesel_%\`.* to 'runner'@'localhost';" -urunner
echo "MYSQL_DATABASE_URL=mysql://runner@localhost/diesel_test" >> $GITHUB_ENV
echo "MYSQL_EXAMPLE_DATABASE_URL=mysql://runner@localhost/diesel_example" >> $GITHUB_ENV
echo "MYSQL_UNIT_TEST_DATABASE_URL=mysql://runner@localhost/diesel_unit_test" >> $GITHUB_ENV
echo "MYSQLCLIENT_LIB_DIR=/opt/homebrew/opt/[email protected]/lib" >> $GITHUB_ENV
echo "MYSQLCLIENT_VERSION=10.5" >> $GITHUB_ENV
/opt/homebrew/opt/[email protected]/bin/mysql -e "create database diesel_test; create database diesel_unit_test; grant all on \`diesel_%\`.* to 'root'@'localhost';" -uroot
echo "MYSQL_DATABASE_URL=mysql://[email protected]/diesel_test" >> $GITHUB_ENV
echo "MYSQL_EXAMPLE_DATABASE_URL=mysql://[email protected]/diesel_example" >> $GITHUB_ENV
echo "MYSQL_UNIT_TEST_DATABASE_URL=mysql://[email protected]/diesel_unit_test" >> $GITHUB_ENV
echo "MYSQLCLIENT_LIB_DIR=/opt/homebrew/opt/[email protected]/lib" >> $GITHUB_ENV
echo "MYSQLCLIENT_VERSION=8.4" >> $GITHUB_ENV

- name: Install sqlite (Windows)
if: runner.os == 'Windows' && matrix.backend == 'sqlite'
shell: cmd
run: |
choco install sqlite
cd /D C:\ProgramData\chocolatey\lib\SQLite\tools
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
lib /machine:x64 /def:sqlite3.def /out:sqlite3.lib

- name: Set variables for sqlite (Windows)
Expand All @@ -194,37 +200,42 @@ jobs:
if: runner.os == 'Windows' && matrix.backend == 'postgres'
shell: bash
run: |
choco install postgresql12 --force --params '/Password:root'
echo "C:\Program Files\PostgreSQL\12\bin" >> $GITHUB_PATH
echo "C:\Program Files\PostgreSQL\12\lib" >> $GITHUB_PATH
echo "PQ_LIB_DIR=C:\Program Files\PostgreSQL\12\lib" >> $GITHUB_ENV
choco install postgresql14 --force --params '/Password:root'
echo "OPENSSL_RUST_USE_NASM=0" >> $GITHUB_ENV
echo OPENSSL_SRC_PERL=C:/Strawberry/perl/bin/perl >> $GITHUB_ENV
echo "PQ_LIB_DIR=C:\Program Files\PostgreSQL\14\lib" >> $GITHUB_ENV
echo "PG_DATABASE_URL=postgres://postgres:root@localhost/" >> $GITHUB_ENV
echo "PG_EXAMPLE_DATABASE_URL=postgres://postgres:root@localhost/diesel_example" >> $GITHUB_ENV

- name: Install mysql (Windows)
if: runner.os == 'Windows' && matrix.backend == 'mysql'
shell: cmd
run: |
choco install mysql
"C:\tools\mysql\current\bin\mysql" -e "create database diesel_test; create database diesel_unit_test; grant all on `diesel_%`.* to 'root'@'localhost';" -uroot

- name: Set variables for mysql (Windows)
if: runner.os == 'Windows' && matrix.backend == 'mysql'
shell: bash
run: |
echo "MYSQL_DATABASE_URL=mysql://root@localhost/diesel_test" >> $GITHUB_ENV
echo "MYSQL_EXAMPLE_DATABASE_URL=mysql://root@localhost/diesel_example" >> $GITHUB_ENV
echo "MYSQL_UNIT_TEST_DATABASE_URL=mysql://root@localhost/diesel_unit_test" >> $GITHUB_ENV
echo "MYSQLCLIENT_LIB_DIR=C:\tools\mysql\current\lib" >> $GITHUB_ENV
echo "MYSQLCLIENT_VERSION=8.0.31" >> $GITHUB_ENV
echo "C:\tools\mysql\current\lib" >> $GITHUB_PATH
echo "C:\tools\mysql\current\bin" >> $GITHUB_PATH
dir "C:\tools\mysql\current\lib"
mkdir "C:\\Program Files\\MySQL\\MySQL Server 8.0\\data\\"
"C:\\Program Files\\MySQL\MySQL Server 8.0\\bin\\mysqld" --console --initialize --initialize-insecure
"C:\\Program Files\\MySQL\MySQL Server 8.0\\bin\\mysqld" --console &
sleep 15
"C:\\Program Files\\MySQL\\MySQL Server 8.0\\bin\\mysql" -e "create database diesel_test;" -u root
"C:\\Program Files\\MySQL\\MySQL Server 8.0\\bin\\mysql" -e "create database diesel_unit_test;" -u root
"C:\\Program Files\\MySQL\\MySQL Server 8.0\\bin\\mysql" -e 'grant all on `diesel_%`.* to 'root'@'localhost';' -uroot
# remove doxygen because mysqlclient build otherwise breaks?
rm "C:/Strawberry/c/bin/doxygen.exe"
echo "OPENSSL_RUST_USE_NASM=0" >> $GITHUB_ENV
echo OPENSSL_SRC_PERL=C:/Strawberry/perl/bin/perl >> $GITHUB_ENV
echo "MYSQL_DATABASE_URL=mysql://[email protected]/diesel_test" >> $GITHUB_ENV
echo "MYSQL_EXAMPLE_DATABASE_URL=mysql://[email protected]/diesel_example" >> $GITHUB_ENV
echo "MYSQL_UNIT_TEST_DATABASE_URL=mysql://[email protected]/diesel_unit_test" >> $GITHUB_ENV
echo "MYSQLCLIENT_LIB_DIR=C:\Program Files\MySQL\MySQL Server 8.0\lib" >> $GITHUB_ENV
echo "MYSQLCLIENT_VERSION=8.0.40" >> $GITHUB_ENV
echo "C:\Program Files\MySQL\MySQL Server 8.0\lib" >> $GITHUB_PATH
echo "C:\Program Files\MySQL\MySQL Server 8.0\bin" >> $GITHUB_PATH
dir "C:\Program Files\MySQL\MySQL Server 8.0\lib"

- name: Install rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
components: rustfmt

- name: Rust version check
shell: bash
Expand Down Expand Up @@ -507,9 +518,10 @@ jobs:
key: mysql_bundled-cargo-${{ hashFiles('**/Cargo.toml') }}
- name: Install Mysql (Linux)
run: |
sudo systemctl start mysql.service
sudo apt-get update
sudo apt-get -y install libmysqlclient-dev llvm
sudo systemctl start mysql.service
sleep 5
mysql -e "create database diesel_test; create database diesel_unit_test; grant all on \`diesel_%\`.* to 'root'@'localhost';" -uroot -proot
echo "MYSQL_DATABASE_URL=mysql://root:[email protected]/diesel_test" >> $GITHUB_ENV
echo "MYSQL_EXAMPLE_DATABASE_URL=mysql://root:[email protected]/diesel_example" >> $GITHUB_ENV
Expand Down
16 changes: 12 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ Increasing the minimal supported Rust version will always be coupled at least wi

## Unreleased

## [2.2.7] 2025-01-31

### Fixed

* Fixed diesel thinking `a.eq_any(b)` was non-nullable even if `a` and `b` were nullable.
* Generate `InstrumentationEvent::BeginTransaction` for immediate and exclusive transactions in SQLite
* Updated `ipnetwork` to allow version 0.21.
* Updated `libsqlite3-sys` to allow version 0.31.0
* Updated `pq-sys` to allow version 0.7.0
* Add support for numeric operators (+-*/) in `#[diesel::auto_type]`
* Add support for joins to sub-jons to aliases

## [2.2.6] 2024-12-03

### Fixed
Expand Down Expand Up @@ -2161,7 +2173,3 @@ queries or set `PIPES_AS_CONCAT` manually.
[2.2.0]: https://github.com/diesel-rs/diesel/compare/v.2.1.0...v2.2.0
[2.2.1]: https://github.com/diesel-rs/diesel/compare/v.2.2.0...v2.2.1
[2.2.2]: https://github.com/diesel-rs/diesel/compare/v.2.2.1...v2.2.2
[2.2.3]: https://github.com/diesel-rs/diesel/compare/v.2.2.2...v2.2.3
[2.2.4]: https://github.com/diesel-rs/diesel/compare/v.2.2.3...v2.2.4
[2.2.5]: https://github.com/diesel-rs/diesel/compare/v.2.2.4...v2.2.5
[2.2.6]: https://github.com/diesel-rs/diesel/compare/v.2.2.5...v2.2.6
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ rust-version = "1.78.0"
include = ["src/**/*.rs", "tests/**/*.rs", "LICENSE-*", "README.md"]

[workspace.dependencies]
libsqlite3-sys = "0.30.1"
libsqlite3-sys = ">=0.30.1,<0.32.0"

# Config for 'cargo dist'
[workspace.metadata.dist]
Expand Down
10 changes: 5 additions & 5 deletions diesel/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "diesel"
version = "2.2.6"
version = "2.2.7"
license = "MIT OR Apache-2.0"
description = "A safe, extensible ORM and Query Builder for PostgreSQL, SQLite, and MySQL"
readme = "README.md"
Expand All @@ -24,17 +24,17 @@ include = [
byteorder = { version = "1.0", optional = true }
chrono = { version = "0.4.20", optional = true, default-features = false, features = ["clock", "std"] }
libc = { version = "0.2.0", optional = true }
libsqlite3-sys = { version = ">=0.17.2, <0.31.0", optional = true, features = ["bundled_bindings"] }
libsqlite3-sys = { version = ">=0.17.2, <0.32.0", optional = true, features = ["bundled_bindings"] }
mysqlclient-sys = { version = ">=0.2.5, <0.5.0", optional = true }
mysqlclient-src = { version = "0.1.0", optional = true }
pq-sys = { version = ">=0.4.0, <0.7.0", optional = true }
pq-sys = { version = ">=0.4.0, <0.8.0", optional = true }
pq-src = { version = "0.3", optional = true }
quickcheck = { version = "1.0.3", optional = true }
serde_json = { version = ">=0.8.0, <2.0", optional = true }
url = { version = "2.1.0", optional = true }
percent-encoding = { version = "2.1.0", optional = true }
uuid = { version = ">=0.7.0, <2.0.0", optional = true }
ipnetwork = { version = ">=0.12.2, <0.21.0", optional = true }
ipnetwork = { version = ">=0.12.2, <0.22.0", optional = true }
ipnet = { version = "2.5.0", optional = true }
num-bigint = { version = ">=0.2.0, <0.5.0", optional = true }
num-traits = { version = "0.2.0", optional = true }
Expand All @@ -52,7 +52,7 @@ path = "../diesel_derives"
[dev-dependencies]
cfg-if = "1"
dotenvy = "0.15"
ipnetwork = ">=0.12.2, <0.21.0"
ipnetwork = ">=0.12.2, <0.22.0"
quickcheck = "1.0.3"
tempfile = "3.10.1"

Expand Down
2 changes: 1 addition & 1 deletion diesel/src/associations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ pub trait HasTable {
fn table() -> Self::Table;
}

impl<'a, T: HasTable> HasTable for &'a T {
impl<T: HasTable> HasTable for &T {
type Table = T::Table;

fn table() -> Self::Table {
Expand Down
17 changes: 10 additions & 7 deletions diesel/src/connection/instrumentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ impl DebugQuery for StrQueryHelper<'_> {}
/// implementation of the enum itself and any of its fields
/// is not guarantee to be stable.
//
// This types is carefully designed
// This type is carefully designed
// to avoid any potential overhead by
// taking references for all things
// and by not performing any additional
// work until required.
// In addition it's carefully designed
// not to be dependent on the actual backend
// type, as that makes it easier to to reuse
// type, as that makes it easier to reuse
// `Instrumentation` implementations in
// different a different context
// a different context
#[derive(Debug)]
#[non_exhaustive]
pub enum InstrumentationEvent<'a> {
Expand Down Expand Up @@ -173,6 +173,7 @@ pub enum InstrumentationEvent<'a> {
// these constructors exist to
// keep `#[non_exhaustive]` on all the variants
// and to gate the constructors on the unstable feature
#[cfg(feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes")]
impl<'a> InstrumentationEvent<'a> {
/// Create a new `InstrumentationEvent::StartEstablishConnection` event
#[cfg(feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes")]
Expand Down Expand Up @@ -243,7 +244,7 @@ impl<'a> InstrumentationEvent<'a> {
/// `tracing` and `log` are supposed to be part of their own
/// crates.
pub trait Instrumentation: Send + 'static {
/// The function that is invoced for each event
/// The function that is invoked for each event
fn on_connection_event(&mut self, event: InstrumentationEvent<'_>);
}

Expand All @@ -266,9 +267,11 @@ pub fn get_default_instrumentation() -> Option<Box<dyn Instrumentation>> {
///
/// // a simple logger that prints all events to stdout
/// fn simple_logger() -> Option<Box<dyn Instrumentation>> {
/// // we need the explicit argument type there due
/// // to bugs in rustc
/// Some(Box::new(|event: InstrumentationEvent<'_>| println!("{event:?}")))
/// // we need the explicit argument type there due
/// // to bugs in rustc
/// Some(Box::new(|event: InstrumentationEvent<'_>| {
/// println!("{event:?}")
/// }))
/// }
///
/// set_default_instrumentation(simple_logger);
Expand Down
5 changes: 4 additions & 1 deletion diesel/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,9 @@ pub(crate) mod private {
where
T: super::LoadConnection<B>,
{
type Cursor<'conn, 'query> = <T as super::LoadConnection<B>>::Cursor<'conn, 'query> where T: 'conn;
type Cursor<'conn, 'query>
= <T as super::LoadConnection<B>>::Cursor<'conn, 'query>
where
T: 'conn;
}
}
4 changes: 2 additions & 2 deletions diesel/src/connection/statement_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ pub enum MaybeCached<'a, T: 'a> {
Cached(&'a mut T),
}

impl<'a, T> Deref for MaybeCached<'a, T> {
impl<T> Deref for MaybeCached<'_, T> {
type Target = T;

fn deref(&self) -> &Self::Target {
Expand All @@ -305,7 +305,7 @@ impl<'a, T> Deref for MaybeCached<'a, T> {
}
}

impl<'a, T> DerefMut for MaybeCached<'a, T> {
impl<T> DerefMut for MaybeCached<'_, T> {
fn deref_mut(&mut self) -> &mut Self::Target {
match *self {
MaybeCached::CannotCache(ref mut x) => x,
Expand Down
Loading
Loading