Skip to content

wasm32 support on top of sqlx 0.5.5 #5

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

Merged
merged 3 commits into from
Jun 2, 2021
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
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.5.5 - 2021-05-24

- [[#1242]] Fix infinite loop at compile time when using query macros [[@toshokan]]

[#1242]: https://github.com/launchbadge/sqlx/pull/1242

## 0.5.4 - 2021-05-22

- [[#1235]] Fix compilation with rustls from an eager update to webpki [[@ETCaton]]

[#1235]: https://github.com/launchbadge/sqlx/pull/1235

## 0.5.3 - 2021-05-21

- [[#1211]] Even more tweaks and fixes to the Pool internals [[@abonander]]
Expand Down Expand Up @@ -911,3 +923,5 @@ Fix docs.rs build by enabling a runtime feature in the docs.rs metadata in `Carg
[@guylapid]: https://github.com/guylapid
[@natproach]: https://github.com/NatPRoach
[@feikesteenbergen]: https://github.com/feikesteenbergen
[@etcaton]: https://github.com/ETCaton
[@toshokan]: https://github.com/toshokan
71 changes: 66 additions & 5 deletions Cargo.lock

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

35 changes: 25 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ members = [
"sqlx-rt",
"sqlx-macros",
"sqlx-test",
"sqlx-wasm-test",
"sqlx-cli",
"sqlx-bench",
"examples/mysql/todos",
Expand All @@ -17,7 +18,7 @@ members = [

[package]
name = "sqlx"
version = "0.5.3"
version = "0.5.5"
license = "MIT OR Apache-2.0"
readme = "README.md"
repository = "https://github.com/launchbadge/sqlx"
Expand Down Expand Up @@ -103,17 +104,11 @@ runtime-tokio-rustls = [
"sqlx-macros/runtime-tokio-rustls",
"_rt-tokio",
]
runtime-wasm-bindgen = [
"sqlx-core/runtime-wasm-bindgen",
"sqlx-macros/runtime-wasm-bindgen",
"_rt-wasm-bindgen",
]


# for conditional compilation
_rt-actix = []
_rt-async-std = []
_rt-tokio = []
_rt-wasm-bindgen = []

# database
any = ["sqlx-core/any"]
Expand All @@ -135,8 +130,8 @@ bstr = ["sqlx-core/bstr"]
git2 = ["sqlx-core/git2"]

[dependencies]
sqlx-core = { version = "0.5.3", path = "sqlx-core", default-features = false }
sqlx-macros = { version = "0.5.3", path = "sqlx-macros", default-features = false, optional = true }
sqlx-core = { version = "0.5.5", path = "sqlx-core", default-features = false }
sqlx-macros = { version = "0.5.5", path = "sqlx-macros", default-features = false, optional = true }

[dev-dependencies]
anyhow = "1.0.31"
Expand Down Expand Up @@ -259,6 +254,26 @@ name = "postgres-derives"
path = "tests/postgres/derives.rs"
required-features = ["postgres", "macros"]

[[test]]
name = "pg-deletes-bench"
path = "tests/postgres/deletes_custom_bench.rs"
required-features = ["postgres"]

[[test]]
name = "pg-updates-bench"
path = "tests/postgres/updates_custom_bench.rs"
required-features = ["postgres"]

[[test]]
name = "pg-inserts-bench"
path = "tests/postgres/inserts_custom_bench.rs"
required-features = ["postgres"]

[[test]]
name = "pg-selects-bench"
path = "tests/postgres/selects_custom_bench.rs"
required-features = ["postgres"]

#
# Microsoft SQL Server (MSSQL)
#
Expand Down
4 changes: 2 additions & 2 deletions sqlx-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sqlx-cli"
version = "0.5.3"
version = "0.5.5"
description = "Command-line utility for SQLx, the Rust SQL toolkit."
edition = "2018"
readme = "README.md"
Expand All @@ -27,7 +27,7 @@ path = "src/bin/cargo-sqlx.rs"
[dependencies]
dotenv = "0.15"
tokio = { version = "1.0.1", features = ["macros", "rt", "rt-multi-thread"] }
sqlx = { version = "0.5.3", path = "..", default-features = false, features = [
sqlx = { version = "0.5.5", path = "..", default-features = false, features = [
"runtime-async-std-native-tls",
"migrate",
"any",
Expand Down
10 changes: 5 additions & 5 deletions sqlx-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sqlx-core"
version = "0.5.3"
version = "0.5.5"
repository = "https://github.com/launchbadge/sqlx"
description = "Core of SQLx, the rust SQL toolkit. Not intended to be used directly."
license = "MIT OR Apache-2.0"
Expand Down Expand Up @@ -87,13 +87,10 @@ runtime-async-std-rustls = [
]
runtime-tokio-rustls = ["sqlx-rt/runtime-tokio-rustls", "_tls-rustls", "_rt-tokio"]

runtime-wasm-bindgen = ["sqlx-rt/runtime-wasm-bindgen", "_rt-wasm-bindgen"]

# for conditional compilation
_rt-actix = ["tokio-stream"]
_rt-async-std = []
_rt-tokio = ["tokio-stream"]
_rt-wasm-bindgen = []
_tls-native-tls = []
_tls-rustls = ["rustls", "webpki", "webpki-roots"]

Expand All @@ -103,7 +100,7 @@ offline = ["serde", "either/serde"]
[dependencies]
ahash = "0.7.2"
atoi = "0.4.0"
sqlx-rt = { path = "../sqlx-rt", version = "0.5.3" }
sqlx-rt = { path = "../sqlx-rt", version = "0.5.5" }
base64 = { version = "0.13.0", default-features = false, optional = true, features = ["std"] }
bigdecimal_ = { version = "0.2.0", optional = true, package = "bigdecimal" }
rust_decimal = { version = "1.8.1", optional = true }
Expand Down Expand Up @@ -163,3 +160,6 @@ stringprep = "0.1.2"
bstr = { version = "0.2.14", default-features = false, features = ["std"], optional = true }
git2 = { version = "0.13.12", default-features = false, optional = true }
hashlink = "0.7.0"

[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.2.2", features = ["js"] }
16 changes: 8 additions & 8 deletions sqlx-core/src/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::encode::Encode;
use crate::types::Type;

/// A tuple of arguments to be sent to the database.
#[cfg(not(feature = "_rt-wasm-bindgen"))]
#[cfg(not(target_arch = "wasm32"))]
pub trait Arguments<'q>: Send + Sized + Default {
type Database: Database;

Expand All @@ -19,7 +19,7 @@ pub trait Arguments<'q>: Send + Sized + Default {
T: 'q + Send + Encode<'q, Self::Database> + Type<Self::Database>;
}

#[cfg(feature = "_rt-wasm-bindgen")]
#[cfg(target_arch = "wasm32")]
pub trait Arguments<'q>: Sized + Default {
type Database: Database;

Expand All @@ -33,16 +33,16 @@ pub trait Arguments<'q>: Sized + Default {
T: 'q + Encode<'q, Self::Database> + Type<Self::Database>;
}

#[cfg(not(feature = "_rt-wasm-bindgen"))]
#[cfg(not(target_arch = "wasm32"))]
pub trait IntoArguments<'q, DB: HasArguments<'q>>: Sized + Send {
fn into_arguments(self) -> <DB as HasArguments<'q>>::Arguments;
}

#[cfg(feature = "_rt-wasm-bindgen")]
pub trait IntoArguments<'q, DB: HasArguments<'q>>: Sized {
fn into_arguments(self) -> <DB as HasArguments<'q>>::Arguments;
}
#[cfg(target_arch = "wasm32")]
pub trait IntoArguments<'q, DB: HasArguments<'q>>: Sized {
fn into_arguments(self) -> <DB as HasArguments<'q>>::Arguments;
}

// NOTE: required due to lack of lazy normalization
#[allow(unused_macros)]
macro_rules! impl_into_arguments_for_arguments {
Expand Down
12 changes: 6 additions & 6 deletions sqlx-core/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use crate::database::{Database, HasStatementCache};
use crate::error::Error;
use crate::transaction::Transaction;

#[cfg(not(feature = "_rt-wasm-bindgen"))]
#[cfg(not(target_arch = "wasm32"))]
use futures_core::future::BoxFuture;

#[cfg(feature = "_rt-wasm-bindgen")]
#[cfg(target_arch = "wasm32")]
use futures_core::future::LocalBoxFuture as BoxFuture;

use log::LevelFilter;
Expand All @@ -14,7 +14,7 @@ use std::str::FromStr;
use std::time::Duration;

/// Represents a single database connection.
#[cfg(not(feature = "_rt-wasm-bindgen"))]
#[cfg(not(target_arch = "wasm32"))]
pub trait Connection: Send {
type Database: Database;

Expand Down Expand Up @@ -132,7 +132,7 @@ pub trait Connection: Send {
}
}

#[cfg(feature = "_rt-wasm-bindgen")]
#[cfg(target_arch = "wasm32")]
pub trait Connection {
type Database: Database;

Expand Down Expand Up @@ -276,7 +276,7 @@ impl LogSettings {
}
}

#[cfg(not(feature = "_rt-wasm-bindgen"))]
#[cfg(not(target_arch = "wasm32"))]
pub trait ConnectOptions: 'static + Send + Sync + FromStr<Err = Error> + Debug {
type Connection: Connection + ?Sized;

Expand All @@ -299,7 +299,7 @@ pub trait ConnectOptions: 'static + Send + Sync + FromStr<Err = Error> + Debug {
}
}

#[cfg(feature = "_rt-wasm-bindgen")]
#[cfg(target_arch = "wasm32")]
pub trait ConnectOptions: 'static + FromStr<Err = Error> + Debug {
type Connection: Connection + ?Sized;

Expand Down
Loading