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
5 changes: 0 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion examples/postgres/axum-social-with-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ validator = { version = "0.16.0", features = ["derive"] }
# Auxilliary crates
anyhow = "1.0.58"
dotenvy = "0.15.1"
once_cell = "1.13.0"
thiserror = "2.0.0"
tracing = "0.1.35"

Expand Down
4 changes: 2 additions & 2 deletions examples/postgres/axum-social-with-tests/src/http/user.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use axum::http::StatusCode;
use axum::{routing::post, Extension, Json, Router};
use once_cell::sync::Lazy;
use rand::Rng;
use regex::Regex;
use std::time::Duration;
use std::cell::LazyCell;

use serde::Deserialize;
use sqlx::{PgExecutor, PgPool};
Expand All @@ -18,7 +18,7 @@ pub fn router() -> Router {
Router::new().route("/v1/user", post(create_user))
}

static USERNAME_REGEX: Lazy<Regex> = Lazy::new(|| Regex::new(r"^[0-9A-Za-z_]+$").unwrap());
static USERNAME_REGEX: LazyCell<Regex> = LazyCell::new(|| Regex::new(r"^[0-9A-Za-z_]+$").unwrap());

// CREATE USER

Expand Down
1 change: 0 additions & 1 deletion sqlx-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ futures-intrusive = "0.5.0"
futures-util = { version = "0.3.19", default-features = false, features = ["alloc", "sink", "io"] }
log = { version = "0.4.18", default-features = false }
memchr = { version = "2.4.1", default-features = false }
once_cell = "1.9.0"
percent-encoding = "2.1.0"
regex = { version = "1.5.5", optional = true }
serde = { version = "1.0.132", features = ["derive", "rc"], optional = true }
Expand Down
2 changes: 1 addition & 1 deletion sqlx-core/src/any/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use crate::connection::Connection;
use crate::database::Database;
use crate::Error;
use futures_core::future::BoxFuture;
use once_cell::sync::OnceCell;
use std::fmt::{Debug, Formatter};
use std::cell::OnceCell;
use url::Url;

static DRIVERS: OnceCell<&'static [AnyDriver]> = OnceCell::new();
Expand Down
1 change: 0 additions & 1 deletion sqlx-macros-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ dotenvy = { workspace = true }
hex = { version = "0.4.3" }
heck = { version = "0.5" }
either = "1.6.1"
once_cell = "1.9.0"
proc-macro2 = { version = "1.0.79", default-features = false }
serde = { version = "1.0.132", features = ["derive"] }
serde_json = { version = "1.0.73" }
Expand Down
7 changes: 3 additions & 4 deletions sqlx-macros-core/src/database/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use std::collections::hash_map;
use std::collections::HashMap;
use std::sync::Mutex;

use once_cell::sync::Lazy;
use std::cell::LazyCell;

use sqlx_core::connection::Connection;
use sqlx_core::database::Database;
Expand Down Expand Up @@ -30,14 +29,14 @@ pub trait DatabaseExt: Database + TypeChecking {

#[allow(dead_code)]
pub struct CachingDescribeBlocking<DB: DatabaseExt> {
connections: Lazy<Mutex<HashMap<String, DB::Connection>>>,
connections: LazyCell<Mutex<HashMap<String, DB::Connection>>>,
}

#[allow(dead_code)]
impl<DB: DatabaseExt> CachingDescribeBlocking<DB> {
pub const fn new() -> Self {
CachingDescribeBlocking {
connections: Lazy::new(|| Mutex::new(HashMap::new())),
connections: LazyCell::new(|| Mutex::new(HashMap::new())),
}
}

Expand Down
4 changes: 2 additions & 2 deletions sqlx-macros-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ where
{
#[cfg(feature = "_rt-tokio")]
{
use once_cell::sync::Lazy;
use std::cell::LazyCell;
use tokio::runtime::{self, Runtime};

// We need a single, persistent Tokio runtime since we're caching connections,
// otherwise we'll get "IO driver has terminated" errors.
static TOKIO_RT: Lazy<Runtime> = Lazy::new(|| {
static TOKIO_RT: LazyCell<Runtime> = LazyCell::new(|| {
runtime::Builder::new_current_thread()
.enable_all()
.build()
Expand Down
6 changes: 3 additions & 3 deletions sqlx-macros-core/src/query/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use std::io::Write as _;
use std::marker::PhantomData;
use std::path::{Path, PathBuf};
use std::sync::Mutex;
use std::cell::LazyCell;

use once_cell::sync::Lazy;
use serde::{Serialize, Serializer};

use sqlx_core::database::Database;
Expand Down Expand Up @@ -65,8 +65,8 @@ impl<DB: Database> Serialize for SerializeDbName<DB> {
}
}

static OFFLINE_DATA_CACHE: Lazy<Mutex<HashMap<PathBuf, DynQueryData>>> =
Lazy::new(Default::default);
static OFFLINE_DATA_CACHE: LazyCell<Mutex<HashMap<PathBuf, DynQueryData>>> =
LazyCell::new(Default::default);

/// Offline query data
#[derive(Clone, serde::Deserialize)]
Expand Down
6 changes: 3 additions & 3 deletions sqlx-macros-core/src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::collections::HashMap;
use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex};
use std::{fs, io};
use std::cell::LazyCell;

use once_cell::sync::Lazy;
use proc_macro2::TokenStream;
use syn::Type;

Expand Down Expand Up @@ -108,7 +108,7 @@ impl Metadata {
}
}

static METADATA: Lazy<Mutex<HashMap<String, Metadata>>> = Lazy::new(Default::default);
static METADATA: LazyCell<Mutex<HashMap<String, Metadata>>> = LazyCell::new(Default::default);

// If we are in a workspace, lookup `workspace_root` since `CARGO_MANIFEST_DIR` won't
// reflect the workspace dir: https://github.com/rust-lang/cargo/issues/3946
Expand Down Expand Up @@ -198,7 +198,7 @@ pub fn expand_input<'a>(
database_url_parsed,
..
} => Err(format!(
"no database driver found matching URL scheme {:?}; the corresponding Cargo feature may need to be enabled",
"no database driver found matching URL scheme {:?}; the corresponding Cargo feature may need to be enabled",
database_url_parsed.scheme()
).into()),
QueryDataSource::Cached(data) => {
Expand Down
1 change: 0 additions & 1 deletion sqlx-mysql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ hex = "0.4.3"
itoa = "1.0.1"
log = "0.4.18"
memchr = { version = "2.4.1", default-features = false }
once_cell = "1.9.0"
percent-encoding = "2.1.0"
smallvec = "1.7.0"
stringprep = "0.1.2"
Expand Down
4 changes: 2 additions & 2 deletions sqlx-mysql/src/testing/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::ops::Deref;
use std::str::FromStr;
use std::time::Duration;
use std::cell::OnceCell;

use futures_core::future::BoxFuture;

Expand All @@ -9,7 +10,6 @@ use crate::executor::Executor;
use crate::pool::{Pool, PoolOptions};
use crate::query::query;
use crate::{MySql, MySqlConnectOptions, MySqlConnection, MySqlDatabaseError};
use once_cell::sync::OnceCell;
use sqlx_core::connection::Connection;
use sqlx_core::query_builder::QueryBuilder;
use sqlx_core::query_scalar::query_scalar;
Expand Down Expand Up @@ -152,7 +152,7 @@ async fn test_context(args: &TestArgs) -> Result<TestContext<MySql>, Error> {
-- BLOB/TEXT columns can only be used as index keys with a prefix length:
-- https://dev.mysql.com/doc/refman/8.4/en/column-indexes.html#column-indexes-prefix
primary key(db_name(63))
);
);
"#,
)
.await?;
Expand Down
1 change: 0 additions & 1 deletion sqlx-postgres/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ itoa = "1.0.1"
log = "0.4.18"
memchr = { version = "2.4.1", default-features = false }
num-bigint = { version = "0.4.3", optional = true }
once_cell = "1.9.0"
smallvec = { version = "1.7.0", features = ["serde"] }
stringprep = "0.1.2"
thiserror = "2.0.0"
Expand Down
2 changes: 1 addition & 1 deletion sqlx-postgres/src/advisory_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use crate::error::Result;
use crate::Either;
use crate::PgConnection;
use hkdf::Hkdf;
use once_cell::sync::OnceCell;
use sha2::Sha256;
use std::ops::{Deref, DerefMut};
use std::cell::OnceCell;

/// A mutex-like type utilizing [Postgres advisory locks].
///
Expand Down
4 changes: 2 additions & 2 deletions sqlx-postgres/src/testing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use std::fmt::Write;
use std::ops::Deref;
use std::str::FromStr;
use std::time::Duration;
use std::cell::OnceCell;

use futures_core::future::BoxFuture;

use once_cell::sync::OnceCell;
use sqlx_core::connection::Connection;
use sqlx_core::query_scalar::query_scalar;

Expand Down Expand Up @@ -146,7 +146,7 @@ async fn test_context(args: &TestArgs) -> Result<TestContext<Postgres>, Error> {
created_at timestamptz not null default now()
);

create index if not exists databases_created_at
create index if not exists databases_created_at
on _sqlx_test.databases(created_at);

create sequence if not exists _sqlx_test.database_ids;
Expand Down
Loading