Skip to content

Commit 38d57b5

Browse files
wasm32 support on top of sqlx 0.5.5 (#5)
* wip: remove runtime-wasm-bindgen; use target_arch instead * remove trait imports from futures_util::io * fix compilation errors
1 parent c88c401 commit 38d57b5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1837
-254
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## 0.5.5 - 2021-05-24
9+
10+
- [[#1242]] Fix infinite loop at compile time when using query macros [[@toshokan]]
11+
12+
[#1242]: https://github.com/launchbadge/sqlx/pull/1242
13+
14+
## 0.5.4 - 2021-05-22
15+
16+
- [[#1235]] Fix compilation with rustls from an eager update to webpki [[@ETCaton]]
17+
18+
[#1235]: https://github.com/launchbadge/sqlx/pull/1235
19+
820
## 0.5.3 - 2021-05-21
921

1022
- [[#1211]] Even more tweaks and fixes to the Pool internals [[@abonander]]
@@ -911,3 +923,5 @@ Fix docs.rs build by enabling a runtime feature in the docs.rs metadata in `Carg
911923
[@guylapid]: https://github.com/guylapid
912924
[@natproach]: https://github.com/NatPRoach
913925
[@feikesteenbergen]: https://github.com/feikesteenbergen
926+
[@etcaton]: https://github.com/ETCaton
927+
[@toshokan]: https://github.com/toshokan

Cargo.lock

Lines changed: 66 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ members = [
55
"sqlx-rt",
66
"sqlx-macros",
77
"sqlx-test",
8+
"sqlx-wasm-test",
89
"sqlx-cli",
910
"sqlx-bench",
1011
"examples/mysql/todos",
@@ -17,7 +18,7 @@ members = [
1718

1819
[package]
1920
name = "sqlx"
20-
version = "0.5.3"
21+
version = "0.5.5"
2122
license = "MIT OR Apache-2.0"
2223
readme = "README.md"
2324
repository = "https://github.com/launchbadge/sqlx"
@@ -103,17 +104,11 @@ runtime-tokio-rustls = [
103104
"sqlx-macros/runtime-tokio-rustls",
104105
"_rt-tokio",
105106
]
106-
runtime-wasm-bindgen = [
107-
"sqlx-core/runtime-wasm-bindgen",
108-
"sqlx-macros/runtime-wasm-bindgen",
109-
"_rt-wasm-bindgen",
110-
]
111-
107+
112108
# for conditional compilation
113109
_rt-actix = []
114110
_rt-async-std = []
115111
_rt-tokio = []
116-
_rt-wasm-bindgen = []
117112

118113
# database
119114
any = ["sqlx-core/any"]
@@ -135,8 +130,8 @@ bstr = ["sqlx-core/bstr"]
135130
git2 = ["sqlx-core/git2"]
136131

137132
[dependencies]
138-
sqlx-core = { version = "0.5.3", path = "sqlx-core", default-features = false }
139-
sqlx-macros = { version = "0.5.3", path = "sqlx-macros", default-features = false, optional = true }
133+
sqlx-core = { version = "0.5.5", path = "sqlx-core", default-features = false }
134+
sqlx-macros = { version = "0.5.5", path = "sqlx-macros", default-features = false, optional = true }
140135

141136
[dev-dependencies]
142137
anyhow = "1.0.31"
@@ -259,6 +254,26 @@ name = "postgres-derives"
259254
path = "tests/postgres/derives.rs"
260255
required-features = ["postgres", "macros"]
261256

257+
[[test]]
258+
name = "pg-deletes-bench"
259+
path = "tests/postgres/deletes_custom_bench.rs"
260+
required-features = ["postgres"]
261+
262+
[[test]]
263+
name = "pg-updates-bench"
264+
path = "tests/postgres/updates_custom_bench.rs"
265+
required-features = ["postgres"]
266+
267+
[[test]]
268+
name = "pg-inserts-bench"
269+
path = "tests/postgres/inserts_custom_bench.rs"
270+
required-features = ["postgres"]
271+
272+
[[test]]
273+
name = "pg-selects-bench"
274+
path = "tests/postgres/selects_custom_bench.rs"
275+
required-features = ["postgres"]
276+
262277
#
263278
# Microsoft SQL Server (MSSQL)
264279
#

sqlx-cli/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "sqlx-cli"
3-
version = "0.5.3"
3+
version = "0.5.5"
44
description = "Command-line utility for SQLx, the Rust SQL toolkit."
55
edition = "2018"
66
readme = "README.md"
@@ -27,7 +27,7 @@ path = "src/bin/cargo-sqlx.rs"
2727
[dependencies]
2828
dotenv = "0.15"
2929
tokio = { version = "1.0.1", features = ["macros", "rt", "rt-multi-thread"] }
30-
sqlx = { version = "0.5.3", path = "..", default-features = false, features = [
30+
sqlx = { version = "0.5.5", path = "..", default-features = false, features = [
3131
"runtime-async-std-native-tls",
3232
"migrate",
3333
"any",

sqlx-core/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "sqlx-core"
3-
version = "0.5.3"
3+
version = "0.5.5"
44
repository = "https://github.com/launchbadge/sqlx"
55
description = "Core of SQLx, the rust SQL toolkit. Not intended to be used directly."
66
license = "MIT OR Apache-2.0"
@@ -87,13 +87,10 @@ runtime-async-std-rustls = [
8787
]
8888
runtime-tokio-rustls = ["sqlx-rt/runtime-tokio-rustls", "_tls-rustls", "_rt-tokio"]
8989

90-
runtime-wasm-bindgen = ["sqlx-rt/runtime-wasm-bindgen", "_rt-wasm-bindgen"]
91-
9290
# for conditional compilation
9391
_rt-actix = ["tokio-stream"]
9492
_rt-async-std = []
9593
_rt-tokio = ["tokio-stream"]
96-
_rt-wasm-bindgen = []
9794
_tls-native-tls = []
9895
_tls-rustls = ["rustls", "webpki", "webpki-roots"]
9996

@@ -103,7 +100,7 @@ offline = ["serde", "either/serde"]
103100
[dependencies]
104101
ahash = "0.7.2"
105102
atoi = "0.4.0"
106-
sqlx-rt = { path = "../sqlx-rt", version = "0.5.3" }
103+
sqlx-rt = { path = "../sqlx-rt", version = "0.5.5" }
107104
base64 = { version = "0.13.0", default-features = false, optional = true, features = ["std"] }
108105
bigdecimal_ = { version = "0.2.0", optional = true, package = "bigdecimal" }
109106
rust_decimal = { version = "1.8.1", optional = true }
@@ -163,3 +160,6 @@ stringprep = "0.1.2"
163160
bstr = { version = "0.2.14", default-features = false, features = ["std"], optional = true }
164161
git2 = { version = "0.13.12", default-features = false, optional = true }
165162
hashlink = "0.7.0"
163+
164+
[target.'cfg(target_arch = "wasm32")'.dependencies]
165+
getrandom = { version = "0.2.2", features = ["js"] }

sqlx-core/src/arguments.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::encode::Encode;
55
use crate::types::Type;
66

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

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

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

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

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

41-
#[cfg(feature = "_rt-wasm-bindgen")]
42-
pub trait IntoArguments<'q, DB: HasArguments<'q>>: Sized {
43-
fn into_arguments(self) -> <DB as HasArguments<'q>>::Arguments;
44-
}
45-
41+
#[cfg(target_arch = "wasm32")]
42+
pub trait IntoArguments<'q, DB: HasArguments<'q>>: Sized {
43+
fn into_arguments(self) -> <DB as HasArguments<'q>>::Arguments;
44+
}
45+
4646
// NOTE: required due to lack of lazy normalization
4747
#[allow(unused_macros)]
4848
macro_rules! impl_into_arguments_for_arguments {

sqlx-core/src/connection.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ use crate::database::{Database, HasStatementCache};
22
use crate::error::Error;
33
use crate::transaction::Transaction;
44

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

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

1111
use log::LevelFilter;
@@ -14,7 +14,7 @@ use std::str::FromStr;
1414
use std::time::Duration;
1515

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

@@ -132,7 +132,7 @@ pub trait Connection: Send {
132132
}
133133
}
134134

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

@@ -276,7 +276,7 @@ impl LogSettings {
276276
}
277277
}
278278

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

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

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

0 commit comments

Comments
 (0)