From dcb58b0e2cd6c0fc5eb161fe9db66eeeaa6e5617 Mon Sep 17 00:00:00 2001 From: Austin Bonander Date: Mon, 3 Jul 2023 14:37:37 -0700 Subject: [PATCH] 0.7.0 release (#2575) * WIP preparing 0.7.0 release * fix: re-enable examples * fix doctests in `sqlx-core` * cherry-pick CHANGELOG entry for 0.6.3 * add actions workflow for examples * fix(cli): close connection after running migrations * fix examples * fix(sqlite): fix parsing of URLs via `Any` * fix(example): don't let Postgres `listen` example run forever * fix Postgres `transaction` example --- .github/workflows/examples.yml | 282 +++++++ CHANGELOG.md | 267 ++++++ Cargo.lock | 787 ++++++++++++++++-- Cargo.toml | 39 +- examples/mysql/todos/Cargo.toml | 2 +- examples/mysql/todos/src/main.rs | 2 +- .../axum-social-with-tests/Cargo.toml | 2 +- examples/postgres/files/Cargo.toml | 4 +- examples/postgres/files/src/main.rs | 2 +- examples/postgres/json/Cargo.toml | 6 +- examples/postgres/json/src/main.rs | 2 +- examples/postgres/listen/Cargo.toml | 4 +- examples/postgres/listen/src/main.rs | 44 +- examples/postgres/mockable-todos/Cargo.toml | 2 +- examples/postgres/mockable-todos/src/main.rs | 2 +- examples/postgres/todos/Cargo.toml | 2 +- examples/postgres/todos/src/main.rs | 2 +- examples/postgres/transaction/Cargo.toml | 2 +- examples/postgres/transaction/src/main.rs | 6 +- examples/sqlite/todos/Cargo.toml | 2 +- examples/sqlite/todos/src/main.rs | 4 +- sqlx-cli/src/migrate.rs | 12 + sqlx-core/Cargo.toml | 4 +- sqlx-macros-core/Cargo.toml | 4 +- sqlx-macros/Cargo.toml | 3 +- sqlx-sqlite/src/options/connect.rs | 11 +- 26 files changed, 1392 insertions(+), 107 deletions(-) create mode 100644 .github/workflows/examples.yml diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml new file mode 100644 index 00000000..1e799131 --- /dev/null +++ b/.github/workflows/examples.yml @@ -0,0 +1,282 @@ +name: Examples + +on: + pull_request: + push: + branches: + - main + - '*-dev' + +jobs: + sqlx-cli: + name: Build SQLx CLI + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - uses: Swatinem/rust-cache@v1 + with: + key: sqlx-cli + + - uses: actions-rs/cargo@v1 + with: + command: build + args: > + -p sqlx-cli + --bin sqlx + --release + --no-default-features + --features mysql,postgres,sqlite + + - uses: actions/upload-artifact@v3 + with: + name: sqlx-cli + path: target/release/sqlx + + mysql: + name: MySQL Examples + runs-on: ubuntu-latest + needs: sqlx-cli + + services: + mysql: + image: mysql:latest + env: + MYSQL_ROOT_PASSWORD: password + ports: + - 3306:3306 + + steps: + - name: Get SQLx-CLI + uses: actions/download-artifact@v3 + with: + name: sqlx-cli + # $HOME is interpreted differently by the shell + path: /home/runner/.local/bin + + - run: | + ls -R /home/runner/.local/bin + chmod +x /home/runner/.local/bin/sqlx + echo /home/runner/.local/bin >> $GITHUB_PATH + sleep 10 + + - uses: actions/checkout@v2 + + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - uses: Swatinem/rust-cache@v1 + with: + key: mysql-examples + + - name: Todos (Setup) + working-directory: examples/mysql/todos + env: + DATABASE_URL: mysql://root:password@localhost:3306/todos?ssl-mode=disabled + run: sqlx db setup + + - name: Todos (Run) + uses: actions-rs/cargo@v1 + env: + DATABASE_URL: mysql://root:password@localhost:3306/todos?ssl-mode=disabled + with: + # TODO: test full CLI + command: run + args: -p sqlx-example-mysql-todos + + postgres: + name: PostgreSQL Examples + runs-on: ubuntu-latest + needs: sqlx-cli + + services: + postgres: + image: postgres:latest + env: + POSTGRES_PASSWORD: password + ports: + - 5432:5432 + + steps: + - name: Get SQLx-CLI + uses: actions/download-artifact@v3 + with: + name: sqlx-cli + path: /home/runner/.local/bin + + - run: | + ls -R /home/runner/.local/bin + chmod +x $HOME/.local/bin/sqlx + echo $HOME/.local/bin >> $GITHUB_PATH + sleep 10 + + - uses: actions/checkout@v2 + + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - uses: Swatinem/rust-cache@v1 + with: + key: pg-examples + + - name: Axum Social with Tests (Setup) + working-directory: examples/postgres/axum-social-with-tests + env: + DATABASE_URL: postgres://postgres:password@localhost:5432/axum-social + run: sqlx db setup + + - name: Axum Social with Tests (Check) + uses: actions-rs/cargo@v1 + env: + DATABASE_URL: postgres://postgres:password@localhost:5432/axum-social + with: + command: check + args: -p sqlx-example-postgres-axum-social + + - name: Axum Social with Tests (Test) + uses: actions-rs/cargo@v1 + env: + DATABASE_URL: postgres://postgres:password@localhost:5432/axum-social + with: + command: test + args: -p sqlx-example-postgres-axum-social + + - name: Files (Setup) + working-directory: examples/postgres/files + env: + DATABASE_URL: postgres://postgres:password@localhost:5432/files + run: sqlx db setup + + - name: Files (Run) + uses: actions-rs/cargo@v1 + env: + DATABASE_URL: postgres://postgres:password@localhost:5432/files + with: + command: run + args: -p sqlx-example-postgres-files + + - name: JSON (Setup) + working-directory: examples/postgres/json + env: + DATABASE_URL: postgres://postgres:password@localhost:5432/json + run: sqlx db setup + + - name: JSON (Run) + uses: actions-rs/cargo@v1 + env: + DATABASE_URL: postgres://postgres:password@localhost:5432/json + with: + command: run + args: -p sqlx-example-postgres-json + + - name: Listen (Setup) + working-directory: examples/postgres/listen + env: + DATABASE_URL: postgres://postgres:password@localhost:5432/listen + run: sqlx db create + + - name: Listen (Run) + uses: actions-rs/cargo@v1 + env: + DATABASE_URL: postgres://postgres:password@localhost:5432/listen + with: + command: run + args: -p sqlx-example-postgres-listen + + - name: Mockable TODOs (Setup) + working-directory: examples/postgres/mockable-todos + env: + DATABASE_URL: postgres://postgres:password@localhost:5432/mockable-todos + run: sqlx db setup + + - name: Mockable TODOs (Run) + uses: actions-rs/cargo@v1 + env: + DATABASE_URL: postgres://postgres:password@localhost:5432/mockable-todos + with: + # TODO: test full CLI + command: run + args: -p sqlx-example-postgres-mockable-todos + + - name: TODOs (Setup) + working-directory: examples/postgres/todos + env: + DATABASE_URL: postgres://postgres:password@localhost:5432/todos + run: sqlx db setup + + - name: TODOs (Run) + uses: actions-rs/cargo@v1 + env: + DATABASE_URL: postgres://postgres:password@localhost:5432/todos + with: + # TODO: test full CLI + command: run + args: -p sqlx-example-postgres-todos + + - name: Transaction (Setup) + working-directory: examples/postgres/transaction + env: + DATABASE_URL: postgres://postgres:password@localhost:5432/txn + run: sqlx db setup + + - name: Transaction (Run) + uses: actions-rs/cargo@v1 + env: + DATABASE_URL: postgres://postgres:password@localhost:5432/txn + with: + command: run + args: -p sqlx-example-postgres-transaction + + sqlite: + name: SQLite Examples + runs-on: ubuntu-latest + needs: sqlx-cli + + steps: + - name: Get SQLx-CLI + uses: actions/download-artifact@v3 + with: + name: sqlx-cli + path: /home/runner/.local/bin + + - run: | + ls -R /home/runner/.local/bin + chmod +x /home/runner/.local/bin/sqlx + echo /home/runner/.local/bin >> $GITHUB_PATH + + - uses: actions/checkout@v2 + + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - uses: Swatinem/rust-cache@v1 + with: + key: sqlite-examples + + - name: TODOs (Setup) + env: + DATABASE_URL: sqlite://todos.sqlite + run: sqlx db setup --source=examples/sqlite/todos/migrations + + - name: TODOs (Run) + uses: actions-rs/cargo@v1 + env: + DATABASE_URL: sqlite://todos.sqlite + with: + command: run + args: -p sqlx-example-sqlite-todos diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c37be31..6ddaf824 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,229 @@ 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.7.0 - 2023-06-30 + +At least **70 pull requests** were merged this release cycle! (The exact count is muddied with pull requests for alpha +releases and such.) And we gained 43 new contributors! Thank you to everyone who helped make this release a reality. + +### Breaking +Many revisions were made to query analysis in the SQLite driver; these are all potentially breaking changes +as they can change the output of `sqlx::query!()` _et al_. We'd like to thank [[@tyrelr]] for their numerous PRs to +this area. + +The MSSQL driver has been removed as it was not nearly at the same maturity level as the other drivers. +[As previously announced][sqlx-pro], we have plans to introduce a fully featured replacement as a premium offering, +alongside drivers for other proprietary databases, with the goal to support full-time development on SQLx. + +If interested, please email your inquiry to sqlx@launchbadge.com. + +The offline mode for the queries has been changed to use a separate file per `query!()` invocation, +which is intended to reduce the number of conflicts when merging branches in a project that both modified queries. +See [[#2363]] for details. + +The type ascription override syntax for the query macros has been deprecated, +as parse support for it has been removed in `syn 2.0`, which we'll be upgrading to in the next breaking release. +This can be replaced with type overrides using casting syntax (`as`). +See [[#2483]] for details. + +* [[#1946]]: Fix compile time verification performance regression for sqlite [[@liningpan]] +* [[#1960]]: Fix sqlite update return and order by type inference [[@tyrelr]] +* [[#1984]]: Sqlite EXPLAIN type inference improvements [[@rongcuid]] +* [[#2039]]: Break drivers out into separate crates, clean up some technical debt [[@abonander]] +* [[#2109]]: feat: better database errors [[@saiintbrisson]] +* [[#2094]]: Update libsqlite3-sys to 0.25.1 [[@penberg]] + * Alongside this upgrade, we are now considering the linkage to `libsqlite3-sys` to be **semver-exempt**, + and we reserve the right to upgrade it as necessary. If you are using `libsqlite3-sys` directly or a crate that + links it such as `rusqlite`, you should pin the versions of both crates to avoid breakages from `cargo update`: +```toml +[dependencies] +sqlx = { version = "=0.7.0", features = ["sqlite"] } +rusqlite = "=0.29.0" +``` +* [[#2132]]: fix: use owned Builder pattern for ConnectOptions [[@ar3s3ru]] +* [[#2253]]: Sqlite describe fixes [[@tyrelr]] +* [[#2285]]: `time`: Assume UTC when decoding a DATETIME column in sqlite [[@nstinus]] +* [[#2363]]: [offline] Change prepare to one-file-per-query [[@cycraig]] +* [[#2387]]: PATCH: bump libsqlite3-sys to patched version [[@grantkee]] +* [[#2409]]: fix(#2407): respect the HaltIfNull opcode when determining nullability [[@arlyon]] +* [[#2459]]: limit the number of instructions that can be evaluated [[@tyrelr]] +* [[#2467]]: Add and improve sqlite describe performance benchmarks [[@tyrelr]] +* [[#2491]]: sqlite date macro support [[@Arcayr]] + * Changes `OffsetDateTime` to be the first type used when deserializing a `timestamp` type. +* [[#2496]]: Bump to libsqlite3-sys 0.26 [[@mdecimus]] +* [[#2508]]: Sqlite analytical [[@tyrelr]] + + +### Added +* [[#1850]]: Add client SSL authentication using key-file for Postgres, MySQL and MariaDB [[@ThibsG]] +* [[#2088]]: feat: Add set_connect_options method to Pool [[@moatra]] +* [[#2113]]: Expose PoolOptions for reading [[@FSMaxB]] +* [[#2115]]: Allow using complex types in `try_from` when deriving `FromRow` [[@95ulisse]] +* [[#2116]]: [SQLite] Add option to execute `PRAGMA optimize;` on close of a connection [[@miles170]] +* [[#2189]]: Added regexp support in sqlite [[@VictorKoenders]] +* [[#2224]]: Add From impls for Json [[@dbeckwith]] +* [[#2256]]: add progress handler support to sqlite [[@nbaztec]] +* [[#2366]]: Allow ignoring attributes for deriving FromRow [[@grgi]] +* [[#2369]]: new type support in query_as [[@0xdeafbeef]] +* [[#2379]]: feat: add `Connection::shrink_buffers`, `PoolConnection::close` [[@abonander]] +* [[#2400]]: fix(docs): example of `sqlx_macros_unstable` in config.toml [[@df51d]] +* [[#2469]]: Add Simple format for Uuid for MySQL & SQLite. [[@MidasLamb]] +* [[#2483]]: chore: add deprecation notice for type ascription use [[@saiintbrisson]] +* [[#2506]]: add args to query builder (#2494) [[@cemoktra]] +* [[#2554]]: Impl `AsMut` for advisory lock types (#2520) [[@alilleybrinker]] +* [[#2559]]: Add CLI autocompletion using clap_complete [[@titaniumtraveler]] + + +### Changed +* [[#2185]]: Initial work to switch to `tracing` [[@CosmicHorrorDev]] +* [[#2193]]: Start testing on Postgres 15 and drop Postgres 10 [[@paolobarbolini]] + * We reserve the right to drop support for end-of-lifed database versions [as discussed in our FAQ][faq-db-version]. +* [[#2213]]: Use `let else` statements in favor of macro [[@OverHash]] +* [[#2365]]: Update dependencies [[@paolobarbolini]] +* [[#2371]]: Disable rustls crate logging feature by default up to date [[@sergeiivankov]] +* [[#2373]]: chore: Use tracing's fields to get structured logs [[@jaysonsantos]] +* [[#2393]]: Lower default logging level for statements to Debug [[@bnoctis]] +* [[#2445]]: Traverse symlinks when resolving migrations [[@tgeoghegan]] +* [[#2485]]: chore(sqlx-postgres): replace `dirs` with `home` & `etcetera` [[@utkarshgupta137]] +* [[#2515]]: Bump mac_address to 1.1.5 [[@repnop]] +* [[#2440]]: Update rustls to 0.21, webpki-roots to 0.23 [[@SergioBenitez]] +* [[#2563]]: Update rsa to 0.9 [[@paolobarbolini]] +* [[#2564]]: Update bitflags to v2 [[@paolobarbolini]] +* [[#2565]]: Bump indexmap and ahash [[@paolobarbolini]] +* [[#2574]]: doc: make it clear that `ConnectOptions` types impl `FromStr` [[@abonander]] + +### Fixed +* [[#2098]]: Fix sqlite compilation [[@cycraig]] +* [[#2120]]: fix logical merge conflict [[@tyrelr]] +* [[#2133]]: Postgres OID resolution query does not take into account current `search_path` [[@95ulisse]] +* [[#2156]]: Fixed typo. [[@cdbfoster]] +* [[#2179]]: fix: ensures recover from fail with PgCopyIn [[@andyquinterom]] +* [[#2200]]: Run CI on *-dev branch [[@joehillen]] +* [[#2222]]: Add context to confusing sqlx prepare parse error [[@laundmo]] +* [[#2271]]: feat: support calling Postgres procedures with the macros [[@bgeron]] +* [[#2282]]: Don't run EXPLAIN nullability analysis on Materialize [[@benesch]] +* [[#2319]]: Set whoami default-features to false [[@thedodd]] +* [[#2352]]: Preparing 0.7.0-alpha.1 release [[@abonander]] +* [[#2355]]: Fixed the example code for `sqlx::test` [[@kenkoooo]] +* [[#2367]]: Fix sqlx-cli create, drop, migrate [[@cycraig]] +* [[#2376]]: fix(pool): close when last handle is dropped, extra check in `try_acquire` [[@abonander]] +* [[#2378]]: Fix README build badge [[@dbrgn]] +* [[#2398]]: fix(prepare): store temporary query files inside the workspace [[@aschey]] +* [[#2402]]: fix: drop old time 0.1.44 dep [[@codahale]] +* [[#2413]]: fix(macros-core): use of undeclared `tracked_path` [[@df51d]] +* [[#2420]]: Enable runtime-tokio feature of sqlx when building sqlx-cli [[@paolobarbolini]] +* [[#2453]]: in README.md, correct spelling and grammar [[@vizvasrj]] +* [[#2454]]: fix: ensure fresh test db's aren't accidentally deleted by do_cleanup [[@phlip9]] +* [[#2507]]: Exposing the Oid of PostgreSQL types [[@Razican]] +* [[#2519]]: Use ::std::result::Result::Ok in output.rs [[@southball]] +* [[#2569]]: Fix broken links to mysql error documentation [[@titaniumtraveler]] +* [[#2570]]: Add a newline to the generated JSON files [[@nyurik]] +* [[#2572]]: Do not panic when `PrepareOk` fails to decode [[@stepantubanov]] +* [[#2573]]: fix(sqlite) Do not drop notify mutex guard until after condvar is triggered [[@andrewwhitehead]] + +[sqlx-pro]: https://github.com/launchbadge/sqlx/discussions/1616 + +[faq-db-version]: https://github.com/launchbadge/sqlx/blob/main/FAQ.md#what-database-versions-does-sqlx-support + +[#1850]: https://github.com/launchbadge/sqlx/pull/1850 +[#1946]: https://github.com/launchbadge/sqlx/pull/1946 +[#1960]: https://github.com/launchbadge/sqlx/pull/1960 +[#1984]: https://github.com/launchbadge/sqlx/pull/1984 +[#2039]: https://github.com/launchbadge/sqlx/pull/2039 +[#2088]: https://github.com/launchbadge/sqlx/pull/2088 +[#2092]: https://github.com/launchbadge/sqlx/pull/2092 +[#2094]: https://github.com/launchbadge/sqlx/pull/2094 +[#2098]: https://github.com/launchbadge/sqlx/pull/2098 +[#2109]: https://github.com/launchbadge/sqlx/pull/2109 +[#2113]: https://github.com/launchbadge/sqlx/pull/2113 +[#2115]: https://github.com/launchbadge/sqlx/pull/2115 +[#2116]: https://github.com/launchbadge/sqlx/pull/2116 +[#2120]: https://github.com/launchbadge/sqlx/pull/2120 +[#2132]: https://github.com/launchbadge/sqlx/pull/2132 +[#2133]: https://github.com/launchbadge/sqlx/pull/2133 +[#2156]: https://github.com/launchbadge/sqlx/pull/2156 +[#2179]: https://github.com/launchbadge/sqlx/pull/2179 +[#2185]: https://github.com/launchbadge/sqlx/pull/2185 +[#2189]: https://github.com/launchbadge/sqlx/pull/2189 +[#2193]: https://github.com/launchbadge/sqlx/pull/2193 +[#2200]: https://github.com/launchbadge/sqlx/pull/2200 +[#2213]: https://github.com/launchbadge/sqlx/pull/2213 +[#2222]: https://github.com/launchbadge/sqlx/pull/2222 +[#2224]: https://github.com/launchbadge/sqlx/pull/2224 +[#2253]: https://github.com/launchbadge/sqlx/pull/2253 +[#2256]: https://github.com/launchbadge/sqlx/pull/2256 +[#2271]: https://github.com/launchbadge/sqlx/pull/2271 +[#2282]: https://github.com/launchbadge/sqlx/pull/2282 +[#2285]: https://github.com/launchbadge/sqlx/pull/2285 +[#2319]: https://github.com/launchbadge/sqlx/pull/2319 +[#2352]: https://github.com/launchbadge/sqlx/pull/2352 +[#2355]: https://github.com/launchbadge/sqlx/pull/2355 +[#2363]: https://github.com/launchbadge/sqlx/pull/2363 +[#2365]: https://github.com/launchbadge/sqlx/pull/2365 +[#2366]: https://github.com/launchbadge/sqlx/pull/2366 +[#2367]: https://github.com/launchbadge/sqlx/pull/2367 +[#2369]: https://github.com/launchbadge/sqlx/pull/2369 +[#2371]: https://github.com/launchbadge/sqlx/pull/2371 +[#2373]: https://github.com/launchbadge/sqlx/pull/2373 +[#2376]: https://github.com/launchbadge/sqlx/pull/2376 +[#2378]: https://github.com/launchbadge/sqlx/pull/2378 +[#2379]: https://github.com/launchbadge/sqlx/pull/2379 +[#2387]: https://github.com/launchbadge/sqlx/pull/2387 +[#2393]: https://github.com/launchbadge/sqlx/pull/2393 +[#2398]: https://github.com/launchbadge/sqlx/pull/2398 +[#2400]: https://github.com/launchbadge/sqlx/pull/2400 +[#2402]: https://github.com/launchbadge/sqlx/pull/2402 +[#2408]: https://github.com/launchbadge/sqlx/pull/2408 +[#2409]: https://github.com/launchbadge/sqlx/pull/2409 +[#2413]: https://github.com/launchbadge/sqlx/pull/2413 +[#2420]: https://github.com/launchbadge/sqlx/pull/2420 +[#2440]: https://github.com/launchbadge/sqlx/pull/2440 +[#2445]: https://github.com/launchbadge/sqlx/pull/2445 +[#2453]: https://github.com/launchbadge/sqlx/pull/2453 +[#2454]: https://github.com/launchbadge/sqlx/pull/2454 +[#2459]: https://github.com/launchbadge/sqlx/pull/2459 +[#2467]: https://github.com/launchbadge/sqlx/pull/2467 +[#2469]: https://github.com/launchbadge/sqlx/pull/2469 +[#2483]: https://github.com/launchbadge/sqlx/pull/2483 +[#2485]: https://github.com/launchbadge/sqlx/pull/2485 +[#2491]: https://github.com/launchbadge/sqlx/pull/2491 +[#2496]: https://github.com/launchbadge/sqlx/pull/2496 +[#2506]: https://github.com/launchbadge/sqlx/pull/2506 +[#2507]: https://github.com/launchbadge/sqlx/pull/2507 +[#2508]: https://github.com/launchbadge/sqlx/pull/2508 +[#2515]: https://github.com/launchbadge/sqlx/pull/2515 +[#2519]: https://github.com/launchbadge/sqlx/pull/2519 +[#2554]: https://github.com/launchbadge/sqlx/pull/2554 +[#2559]: https://github.com/launchbadge/sqlx/pull/2559 +[#2563]: https://github.com/launchbadge/sqlx/pull/2563 +[#2564]: https://github.com/launchbadge/sqlx/pull/2564 +[#2565]: https://github.com/launchbadge/sqlx/pull/2565 +[#2569]: https://github.com/launchbadge/sqlx/pull/2569 +[#2570]: https://github.com/launchbadge/sqlx/pull/2570 +[#2572]: https://github.com/launchbadge/sqlx/pull/2572 +[#2573]: https://github.com/launchbadge/sqlx/pull/2573 +[#2574]: https://github.com/launchbadge/sqlx/pull/2574 + +### 0.6.3 - 2023-03-21 + +This is a hotfix to address the breakage caused by transitive dependencies upgrading to `syn = "2"`. + +We set `default-features = false` for our dependency on `syn = "1"` to be good crates.io citizens, +but failed to enable the features we actually used, which went undetected because we transitively depended on +`syn` with the default features enabled through other crates, +and so they were also on for us because features are additive. + +When those other dependencies upgraded to `syn = "2"` it was no longer enabling those features for us, +and so compilation broke for projects that don't also depend on `syn = "1"`, transitively or otherwise. + +There is no PR for this fix as there was no longer a dedicated development branch for `0.6`, +but discussion can be found in [issue #2418]. + +As of this release, the `0.7` release is in alpha and so development is no longer occurring against `0.6`. +This fix will be forward-ported to `0.7`. + +[issue #2418]: https://github.com/launchbadge/sqlx/issues/2418 + ## 0.6.2 - 2022-09-14 [25 pull requests][0.6.2-prs] were merged this release cycle. @@ -1596,3 +1819,47 @@ Fix docs.rs build by enabling a runtime feature in the docs.rs metadata in `Carg [@DXist]: https://github.com/DXist [@Wopple]: https://github.com/Wopple [@TravisWhitehead]: https://github.com/TravisWhitehead +[@ThibsG]: https://github.com/ThibsG +[@rongcuid]: https://github.com/rongcuid +[@moatra]: https://github.com/moatra +[@penberg]: https://github.com/penberg +[@saiintbrisson]: https://github.com/saiintbrisson +[@FSMaxB]: https://github.com/FSMaxB +[@95ulisse]: https://github.com/95ulisse +[@miles170]: https://github.com/miles170 +[@ar3s3ru]: https://github.com/ar3s3ru +[@cdbfoster]: https://github.com/cdbfoster +[@andyquinterom]: https://github.com/andyquinterom +[@CosmicHorrorDev]: https://github.com/CosmicHorrorDev +[@VictorKoenders]: https://github.com/VictorKoenders +[@joehillen]: https://github.com/joehillen +[@OverHash]: https://github.com/OverHash +[@laundmo]: https://github.com/laundmo +[@nbaztec]: https://github.com/nbaztec +[@bgeron]: https://github.com/bgeron +[@benesch]: https://github.com/benesch +[@nstinus]: https://github.com/nstinus +[@grgi]: https://github.com/grgi +[@sergeiivankov]: https://github.com/sergeiivankov +[@jaysonsantos]: https://github.com/jaysonsantos +[@dbrgn]: https://github.com/dbrgn +[@grantkee]: https://github.com/grantkee +[@bnoctis]: https://github.com/bnoctis +[@aschey]: https://github.com/aschey +[@df51d]: https://github.com/df51d +[@codahale]: https://github.com/codahale +[@arlyon]: https://github.com/arlyon +[@SergioBenitez]: https://github.com/SergioBenitez +[@tgeoghegan]: https://github.com/tgeoghegan +[@vizvasrj]: https://github.com/vizvasrj +[@phlip9]: https://github.com/phlip9 +[@MidasLamb]: https://github.com/MidasLamb +[@utkarshgupta137]: https://github.com/utkarshgupta137 +[@Arcayr]: https://github.com/Arcayr +[@mdecimus]: https://github.com/mdecimus +[@Razican]: https://github.com/Razican +[@southball]: https://github.com/southball +[@alilleybrinker]: https://github.com/alilleybrinker +[@titaniumtraveler]: https://github.com/titaniumtraveler +[@nyurik]: https://github.com/nyurik +[@stepantubanov]: https://github.com/stepantubanov \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 29340d36..3185b261 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -49,12 +49,32 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + [[package]] name = "anyhow" version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb07d2053ccdbe10e2af2995a2f116c1330396493dc1269f6a91d0ae82e19704" +[[package]] +name = "argon2" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db4ce4441f99dbd377ca8a8f57b698c44d0d6e712d8329b5040da5a64aa1ce73" +dependencies = [ + "base64ct", + "blake2", + "password-hash", +] + [[package]] name = "arrayvec" version = "0.7.2" @@ -68,7 +88,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3203e79f4dd9bdda415ed03cf14dae5a2bf775c683a00f94e9cd1faf0f596e5" dependencies = [ "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -183,7 +203,7 @@ checksum = "96cf8829f67d2eab0b2dfa42c5d0ef737e0724e4a82b01b3e292456202b19716" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -218,6 +238,66 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "axum" +version = "0.5.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acee9fd5073ab6b045a275b3e709c163dd36c90685219cb21804a147b58dba43" +dependencies = [ + "async-trait", + "axum-core", + "axum-macros", + "bitflags 1.3.2", + "bytes", + "futures-util", + "http", + "http-body", + "hyper", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tower", + "tower-http", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37e5939e02c56fecd5c017c37df4238c0a839fa76b7f97acdd7efb804fd181cc" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http", + "http-body", + "mime", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-macros" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6293dae2ec708e679da6736e857cf8532886ef258e92930f38279c12641628b8" +dependencies = [ + "heck 0.4.0", + "proc-macro2", + "quote", + "syn 1.0.107", +] + [[package]] name = "backoff" version = "0.4.0" @@ -282,6 +362,15 @@ dependencies = [ "serde", ] +[[package]] +name = "blake2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" +dependencies = [ + "digest", +] + [[package]] name = "block-buffer" version = "0.10.2" @@ -325,7 +414,7 @@ dependencies = [ "borsh-schema-derive-internal", "proc-macro-crate", "proc-macro2", - "syn", + "syn 1.0.107", ] [[package]] @@ -336,7 +425,7 @@ checksum = "186b734fa1c9f6743e90c95d7233c9faab6360d1a96d4ffa19d9cfd1e9350f8a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -347,7 +436,7 @@ checksum = "99b7ff1008316626f485991b960ade129253d4034014616b94f309a15366cc49" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -384,7 +473,7 @@ checksum = "13e576ebe98e605500b3c8041bb888e966653577172df6dd97398714eb30b9bf" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -463,6 +552,7 @@ dependencies = [ "iana-time-zone", "num-integer", "num-traits", + "serde", "winapi", ] @@ -493,6 +583,21 @@ dependencies = [ "half", ] +[[package]] +name = "clap" +version = "2.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +dependencies = [ + "ansi_term", + "atty", + "bitflags 1.3.2", + "strsim 0.8.0", + "textwrap 0.11.0", + "unicode-width", + "vec_map", +] + [[package]] name = "clap" version = "3.2.10" @@ -505,9 +610,9 @@ dependencies = [ "clap_lex", "indexmap 1.9.3", "once_cell", - "strsim", + "strsim 0.10.0", "termcolor", - "textwrap", + "textwrap 0.15.0", ] [[package]] @@ -516,7 +621,7 @@ version = "3.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f7a2e0a962c45ce25afce14220bc24f9dade0a1787f185cecf96bfba7847cd8" dependencies = [ - "clap", + "clap 3.2.10", ] [[package]] @@ -525,11 +630,11 @@ version = "3.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "759bf187376e1afa7b85b959e6a664a3e7a95203415dba952ad19139e798f902" dependencies = [ - "heck", + "heck 0.4.0", "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -651,7 +756,7 @@ dependencies = [ "atty", "cast", "ciborium", - "clap", + "clap 3.2.10", "criterion-plot", "futures", "itertools", @@ -750,7 +855,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f877be4f7c9f246b183111634f75baa039715e3f46ce860677d3b19a69fb229c" dependencies = [ "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -777,7 +882,7 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn", + "syn 1.0.107", ] [[package]] @@ -794,7 +899,42 @@ checksum = "086c685979a698443656e5cf7856c95c642295a38599f12fb1ff76fb28d19892" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", +] + +[[package]] +name = "darling" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0558d22a7b463ed0241e993f76f09f30b126687447751a8638587b864e4b3944" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab8bfa2e259f8ee1ce5e97824a3c55ec4404a0d772ca7fa96bf19f0752a046eb" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim 0.10.0", + "syn 2.0.22", +] + +[[package]] +name = "darling_macro" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29a358ff9f12ec09c3e61fef9b5a9902623a695a46a917b07f269bff1445611a" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.22", ] [[package]] @@ -808,6 +948,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "difflib" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" + [[package]] name = "digest" version = "0.10.6" @@ -847,6 +993,12 @@ version = "0.15.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03d8c417d7a8cb362e0c37e5d815f5eb7c37f79ff93707329d5a194e42e54ca0" +[[package]] +name = "downcast" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" + [[package]] name = "either" version = "1.7.0" @@ -976,6 +1128,15 @@ dependencies = [ "windows-sys 0.36.1", ] +[[package]] +name = "float-cmp" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" +dependencies = [ + "num-traits", +] + [[package]] name = "flume" version = "0.10.13" @@ -988,6 +1149,12 @@ dependencies = [ "spin 0.9.3", ] +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + [[package]] name = "foreign-types" version = "0.3.2" @@ -1013,6 +1180,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fragile" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" + [[package]] name = "fuchsia-cprng" version = "0.1.1" @@ -1101,7 +1274,7 @@ checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -1203,6 +1376,15 @@ dependencies = [ "hashbrown 0.12.2", ] +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "heck" version = "0.4.0" @@ -1254,12 +1436,75 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "http" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "http-range-header" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bfe8eed0a9285ef776bb792479ea3834e8b94e13d615c2f66d03dd50a435a29" + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" + [[package]] name = "humantime" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +[[package]] +name = "hyper" +version = "0.14.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abfba89e19b959ca163c7752ba59d737c1ceea53a5d31a149c805446fc958064" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + [[package]] name = "iana-time-zone" version = "0.1.53" @@ -1284,6 +1529,12 @@ dependencies = [ "cxx-build", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "idna" version = "0.2.3" @@ -1295,6 +1546,22 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "idna" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "if_chain" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb56e1aa765b4b4f3aadfab769793b7087bb03a4ea4920644a6d238e2df5b9ed" + [[package]] name = "indexmap" version = "1.9.3" @@ -1303,6 +1570,7 @@ checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown 0.12.2", + "serde", ] [[package]] @@ -1455,6 +1723,12 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" +[[package]] +name = "matchit" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73cbba799671b762df5a175adf59ce145165747bb891505c43d09aefbbf38beb" + [[package]] name = "md-5" version = "0.10.1" @@ -1479,6 +1753,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + [[package]] name = "minimal-lexical" version = "0.2.1" @@ -1497,6 +1777,33 @@ dependencies = [ "windows-sys 0.36.1", ] +[[package]] +name = "mockall" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c84490118f2ee2d74570d114f3d0493cbf02790df303d2707606c3e14e07c96" +dependencies = [ + "cfg-if", + "downcast", + "fragile", + "lazy_static", + "mockall_derive", + "predicates", + "predicates-tree", +] + +[[package]] +name = "mockall_derive" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ce75669015c4f47b289fd4d4f56e894e4c96003ffdf3ac51313126f94c6cbb" +dependencies = [ + "cfg-if", + "proc-macro2", + "quote", + "syn 1.0.107", +] + [[package]] name = "native-tls" version = "0.2.10" @@ -1547,6 +1854,12 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "normalize-line-endings" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" + [[package]] name = "num-bigint" version = "0.4.3" @@ -1651,7 +1964,7 @@ checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -1718,6 +2031,17 @@ dependencies = [ "windows-sys 0.36.1", ] +[[package]] +name = "password-hash" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" +dependencies = [ + "base64ct", + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "paste" version = "1.0.7" @@ -1756,7 +2080,7 @@ checksum = "710faf75e1b33345361201d36d04e98ac1ed8909151a017ed384700836104c74" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -1845,6 +2169,36 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" +[[package]] +name = "predicates" +version = "2.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59230a63c37f3e18569bdb90e4a89cbf5bf8b06fea0b84e65ea10cc4df47addd" +dependencies = [ + "difflib", + "float-cmp", + "itertools", + "normalize-line-endings", + "predicates-core", + "regex", +] + +[[package]] +name = "predicates-core" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b794032607612e7abeb4db69adb4e33590fa6cf1149e95fd7cb00e634b92f174" + +[[package]] +name = "predicates-tree" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "368ba315fb8c5052ab692e68a0eefec6ec57b23a36959c14496f0b0df2c0cecf" +dependencies = [ + "predicates-core", + "termtree", +] + [[package]] name = "proc-macro-crate" version = "0.1.5" @@ -1863,7 +2217,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 1.0.107", "version_check", ] @@ -1880,9 +2234,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.51" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" +checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb" dependencies = [ "unicode-ident", ] @@ -1913,14 +2267,14 @@ checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] name = "quote" -version = "1.0.20" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" +checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" dependencies = [ "proc-macro2", ] @@ -2140,7 +2494,7 @@ checksum = "ff26ed6c7c4dfc2aa9480b86a60e3c7233543a270a680e10758a507c5a4ce476" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -2338,22 +2692,22 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.152" +version = "1.0.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" +checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.152" +version = "1.0.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" +checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.22", ] [[package]] @@ -2367,6 +2721,46 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_with" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07ff71d2c147a7b57362cead5e22f772cd52f6ab31cfcd9edcd7f6aeb2a0afbe" +dependencies = [ + "base64 0.13.0", + "chrono", + "hex", + "indexmap 1.9.3", + "serde", + "serde_json", + "serde_with_macros", + "time", +] + +[[package]] +name = "serde_with_macros" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "881b6f881b17d13214e5d494c939ebab463d01264ce1811e9d4ac3a882e7695f" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.22", +] + [[package]] name = "sha1" version = "0.10.1" @@ -2468,7 +2862,7 @@ dependencies = [ [[package]] name = "sqlx" -version = "0.7.0-alpha.3" +version = "0.7.0" dependencies = [ "anyhow", "async-std", @@ -2498,14 +2892,14 @@ dependencies = [ [[package]] name = "sqlx-cli" -version = "0.7.0-alpha.3" +version = "0.7.0" dependencies = [ "anyhow", "async-trait", "backoff", "cargo_metadata", "chrono", - "clap", + "clap 3.2.10", "clap_complete", "console", "dotenvy", @@ -2524,7 +2918,7 @@ dependencies = [ [[package]] name = "sqlx-core" -version = "0.7.0-alpha.3" +version = "0.7.0" dependencies = [ "ahash 0.8.3", "async-io", @@ -2582,25 +2976,139 @@ dependencies = [ "webpki-roots", ] +[[package]] +name = "sqlx-example-mysql-todos" +version = "0.1.0" +dependencies = [ + "anyhow", + "futures", + "sqlx", + "structopt", + "tokio", +] + +[[package]] +name = "sqlx-example-postgres-axum-social" +version = "0.1.0" +dependencies = [ + "anyhow", + "argon2", + "axum", + "dotenvy", + "once_cell", + "rand 0.8.5", + "regex", + "serde", + "serde_json", + "serde_with", + "sqlx", + "thiserror", + "time", + "tokio", + "tower", + "tracing", + "uuid", + "validator", +] + +[[package]] +name = "sqlx-example-postgres-files" +version = "0.1.0" +dependencies = [ + "anyhow", + "dotenvy", + "sqlx", + "tokio", +] + +[[package]] +name = "sqlx-example-postgres-json" +version = "0.1.0" +dependencies = [ + "anyhow", + "dotenvy", + "futures", + "serde", + "serde_json", + "sqlx", + "structopt", + "tokio", +] + +[[package]] +name = "sqlx-example-postgres-listen" +version = "0.1.0" +dependencies = [ + "futures", + "sqlx", + "tokio", +] + +[[package]] +name = "sqlx-example-postgres-mockable-todos" +version = "0.1.0" +dependencies = [ + "anyhow", + "async-trait", + "dotenvy", + "futures", + "mockall", + "sqlx", + "structopt", + "tokio", +] + +[[package]] +name = "sqlx-example-postgres-todos" +version = "0.1.0" +dependencies = [ + "anyhow", + "dotenvy", + "futures", + "sqlx", + "structopt", + "tokio", +] + +[[package]] +name = "sqlx-example-postgres-transaction" +version = "0.1.0" +dependencies = [ + "futures", + "sqlx", + "tokio", +] + +[[package]] +name = "sqlx-example-sqlite-todos" +version = "0.1.0" +dependencies = [ + "anyhow", + "futures", + "sqlx", + "structopt", + "tokio", +] + [[package]] name = "sqlx-macros" -version = "0.7.0-alpha.3" +version = "0.7.0" dependencies = [ "proc-macro2", "quote", "sqlx-core", "sqlx-macros-core", - "syn", + "syn 1.0.107", ] [[package]] name = "sqlx-macros-core" -version = "0.7.0-alpha.3" +version = "0.7.0" dependencies = [ "async-std", "dotenvy", "either", - "heck", + "heck 0.4.0", "hex", "once_cell", "proc-macro2", @@ -2612,7 +3120,7 @@ dependencies = [ "sqlx-mysql", "sqlx-postgres", "sqlx-sqlite", - "syn", + "syn 1.0.107", "tempfile", "tokio", "url", @@ -2620,7 +3128,7 @@ dependencies = [ [[package]] name = "sqlx-mysql" -version = "0.7.0-alpha.3" +version = "0.7.0" dependencies = [ "atoi", "base64 0.21.0", @@ -2665,7 +3173,7 @@ dependencies = [ [[package]] name = "sqlx-postgres" -version = "0.7.0-alpha.3" +version = "0.7.0" dependencies = [ "atoi", "base64 0.21.0", @@ -2711,7 +3219,7 @@ dependencies = [ [[package]] name = "sqlx-sqlite" -version = "0.7.0-alpha.3" +version = "0.7.0" dependencies = [ "atoi", "chrono", @@ -2762,12 +3270,42 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + [[package]] name = "strsim" version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "structopt" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" +dependencies = [ + "clap 2.34.0", + "lazy_static", + "structopt-derive", +] + +[[package]] +name = "structopt-derive" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" +dependencies = [ + "heck 0.3.3", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.107", +] + [[package]] name = "subtle" version = "2.4.1" @@ -2785,6 +3323,23 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2efbeae7acf4eabd6bcdcbd11c92f45231ddda7539edc7806bd1a04a03b24616" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + [[package]] name = "tempdir" version = "0.3.7" @@ -2828,6 +3383,21 @@ dependencies = [ "winapi", ] +[[package]] +name = "termtree" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + [[package]] name = "textwrap" version = "0.15.0" @@ -2851,7 +3421,7 @@ checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -2935,7 +3505,7 @@ checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -2958,6 +3528,53 @@ dependencies = [ "serde", ] +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "pin-project", + "pin-project-lite", + "tokio", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-http" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f873044bf02dd1e8239e9c1293ea39dad76dc594ec16185d0a1bf31d8dc8d858" +dependencies = [ + "bitflags 1.3.2", + "bytes", + "futures-core", + "futures-util", + "http", + "http-body", + "http-range-header", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + [[package]] name = "tracing" version = "0.1.37" @@ -2979,7 +3596,7 @@ checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -2991,6 +3608,12 @@ dependencies = [ "once_cell", ] +[[package]] +name = "try-lock" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" + [[package]] name = "trybuild" version = "1.0.63" @@ -3014,9 +3637,9 @@ checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" [[package]] name = "unicode-bidi" -version = "0.3.8" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" @@ -3026,9 +3649,9 @@ checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" [[package]] name = "unicode-normalization" -version = "0.1.21" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "854cbdc4f7bc6ae19c820d44abdc3277ac3e1b2b93db20a636825d9322fb60e6" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" dependencies = [ "tinyvec", ] @@ -3064,7 +3687,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" dependencies = [ "form_urlencoded", - "idna", + "idna 0.2.3", "matches", "percent-encoding", ] @@ -3080,6 +3703,51 @@ name = "uuid" version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd6469f4314d5f1ffec476e05f17cc9a78bc7a27a6a857842170bdf8d6f98d2f" +dependencies = [ + "serde", +] + +[[package]] +name = "validator" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b92f40481c04ff1f4f61f304d61793c7b56ff76ac1469f1beb199b1445b253bd" +dependencies = [ + "idna 0.4.0", + "lazy_static", + "regex", + "serde", + "serde_derive", + "serde_json", + "url", + "validator_derive", +] + +[[package]] +name = "validator_derive" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc44ca3088bb3ba384d9aecf40c6a23a676ce23e09bdaca2073d99c207f864af" +dependencies = [ + "if_chain", + "lazy_static", + "proc-macro-error", + "proc-macro2", + "quote", + "regex", + "syn 1.0.107", + "validator_types", +] + +[[package]] +name = "validator_types" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "111abfe30072511849c5910134e8baf8dc05de4c0e5903d681cbd5c9c4d611e3" +dependencies = [ + "proc-macro2", + "syn 1.0.107", +] [[package]] name = "value-bag" @@ -3097,6 +3765,12 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + [[package]] name = "version_check" version = "0.9.4" @@ -3119,6 +3793,15 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -3146,7 +3829,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn", + "syn 1.0.107", "wasm-bindgen-shared", ] @@ -3180,7 +3863,7 @@ checksum = "7d94ac45fcf608c1f45ef53e748d35660f168490c10b23704c7779ab8f5c3048" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", "wasm-bindgen-backend", "wasm-bindgen-shared", ] diff --git a/Cargo.toml b/Cargo.toml index ac4b9e39..2e15292c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,20 +10,19 @@ members = [ "sqlx-mysql", "sqlx-postgres", "sqlx-sqlite", -# FIXME: uncomment these for full release -# "examples/mysql/todos", -# "examples/postgres/axum-social-with-tests", -# "examples/postgres/files", -# "examples/postgres/json", -# "examples/postgres/listen", -# "examples/postgres/todos", -# "examples/postgres/mockable-todos", -# "examples/postgres/transaction", -# "examples/sqlite/todos", + "examples/mysql/todos", + "examples/postgres/axum-social-with-tests", + "examples/postgres/files", + "examples/postgres/json", + "examples/postgres/listen", + "examples/postgres/todos", + "examples/postgres/mockable-todos", + "examples/postgres/transaction", + "examples/sqlite/todos", ] [workspace.package] -version = "0.7.0-alpha.3" +version = "0.7.0" license = "MIT OR Apache-2.0" edition = "2021" repository = "https://github.com/launchbadge/sqlx" @@ -114,17 +113,17 @@ regexp = ["sqlx-sqlite?/regexp"] [workspace.dependencies] # Core Crates -sqlx-core = { version = "=0.7.0-alpha.3", path = "sqlx-core" } -sqlx-macros-core = { version = "=0.7.0-alpha.3", path = "sqlx-macros-core" } -sqlx-macros = { version = "=0.7.0-alpha.3", path = "sqlx-macros" } +sqlx-core = { version = "=0.7.0", path = "sqlx-core" } +sqlx-macros-core = { version = "=0.7.0", path = "sqlx-macros-core" } +sqlx-macros = { version = "=0.7.0", path = "sqlx-macros" } # Driver crates -sqlx-mysql = { version = "=0.7.0-alpha.3", path = "sqlx-mysql" } -sqlx-postgres = { version = "=0.7.0-alpha.3", path = "sqlx-postgres" } -sqlx-sqlite = { version = "=0.7.0-alpha.3", path = "sqlx-sqlite" } +sqlx-mysql = { version = "=0.7.0", path = "sqlx-mysql" } +sqlx-postgres = { version = "=0.7.0", path = "sqlx-postgres" } +sqlx-sqlite = { version = "=0.7.0", path = "sqlx-sqlite" } # Facade crate (for reference from sqlx-cli) -sqlx = { version = "=0.7.0-alpha.3", path = "." } +sqlx = { version = "=0.7.0", path = ".", default-features = false } # Common type integrations shared by multiple driver crates. # These are optional unless enabled in a workspace crate. @@ -150,8 +149,8 @@ features = ["time", "net", "sync", "fs", "io-util", "rt"] default-features = false [dependencies] -sqlx-core = { workspace = true, features = ["offline", "migrate"], default-features = false } -sqlx-macros = { workspace = true, default-features = false, optional = true } +sqlx-core = { workspace = true, features = ["offline", "migrate"] } +sqlx-macros = { workspace = true, optional = true } sqlx-mysql = { workspace = true, optional = true } sqlx-postgres = { workspace = true, optional = true } diff --git a/examples/mysql/todos/Cargo.toml b/examples/mysql/todos/Cargo.toml index 0ffff9c4..167e3909 100644 --- a/examples/mysql/todos/Cargo.toml +++ b/examples/mysql/todos/Cargo.toml @@ -9,4 +9,4 @@ anyhow = "1.0" futures = "0.3" sqlx = { path = "../../../", features = [ "mysql", "runtime-tokio-native-tls" ] } structopt = "0.3" -tokio = { version = "1.20.0", features = ["macros"]} +tokio = { version = "1.20.0", features = ["rt", "macros"]} diff --git a/examples/mysql/todos/src/main.rs b/examples/mysql/todos/src/main.rs index 077a5a5b..34abd300 100644 --- a/examples/mysql/todos/src/main.rs +++ b/examples/mysql/todos/src/main.rs @@ -14,7 +14,7 @@ enum Command { Done { id: u64 }, } -#[tokio::main] +#[tokio::main(flavor = "current_thread")] async fn main() -> anyhow::Result<()> { let args = Args::from_args_safe()?; let pool = MySqlPool::connect(&env::var("DATABASE_URL")?).await?; diff --git a/examples/postgres/axum-social-with-tests/Cargo.toml b/examples/postgres/axum-social-with-tests/Cargo.toml index 509cda20..d03730bd 100644 --- a/examples/postgres/axum-social-with-tests/Cargo.toml +++ b/examples/postgres/axum-social-with-tests/Cargo.toml @@ -8,7 +8,7 @@ edition = "2021" [dependencies] # Primary crates axum = { version = "0.5.13", features = ["macros"] } -sqlx = { version = "0.6.2", path = "../../../", features = ["runtime-tokio-rustls", "postgres", "time", "uuid"] } +sqlx = { path = "../../../", features = ["runtime-tokio-rustls", "postgres", "time", "uuid"] } tokio = { version = "1.20.1", features = ["rt-multi-thread", "macros"] } # Important secondary crates diff --git a/examples/postgres/files/Cargo.toml b/examples/postgres/files/Cargo.toml index 30317e41..bfc99487 100644 --- a/examples/postgres/files/Cargo.toml +++ b/examples/postgres/files/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "files" +name = "sqlx-example-postgres-files" version = "0.1.0" edition = "2021" @@ -8,5 +8,5 @@ edition = "2021" [dependencies] anyhow = "1.0" sqlx = { path = "../../../", features = ["postgres", "runtime-tokio-native-tls"] } -tokio = { version = "1.20.0", features = ["macros"]} +tokio = { version = "1.20.0", features = ["rt", "macros"]} dotenvy = "0.15.0" diff --git a/examples/postgres/files/src/main.rs b/examples/postgres/files/src/main.rs index 789c3ce4..326b3217 100644 --- a/examples/postgres/files/src/main.rs +++ b/examples/postgres/files/src/main.rs @@ -26,7 +26,7 @@ impl Display for PostWithAuthorQuery { } } -#[tokio::main] +#[tokio::main(flavor = "current_thread")] async fn main() -> anyhow::Result<()> { let pool = PgPool::connect(&dotenvy::var("DATABASE_URL")?).await?; diff --git a/examples/postgres/json/Cargo.toml b/examples/postgres/json/Cargo.toml index a0217dc6..4349c07f 100644 --- a/examples/postgres/json/Cargo.toml +++ b/examples/postgres/json/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "json" +name = "sqlx-example-postgres-json" version = "0.1.0" edition = "2021" workspace = "../../../" @@ -10,6 +10,6 @@ dotenvy = "0.15.0" futures = "0.3" serde = { version = "1", features = ["derive"] } serde_json = "1" -sqlx = { path = "../../../", features = ["postgres", "json"] } +sqlx = { path = "../../../", features = ["runtime-tokio", "postgres", "json"] } structopt = "0.3" -tokio = { version = "1.20.0", features = ["macros"]} +tokio = { version = "1.20.0", features = ["rt", "macros"]} diff --git a/examples/postgres/json/src/main.rs b/examples/postgres/json/src/main.rs index 706ae632..ce218d04 100644 --- a/examples/postgres/json/src/main.rs +++ b/examples/postgres/json/src/main.rs @@ -30,7 +30,7 @@ struct Row { person: Json, } -#[tokio::main] +#[tokio::main(flavor = "current_thread")] async fn main() -> anyhow::Result<()> { let args = Args::from_args_safe()?; let pool = PgPool::connect(&dotenvy::var("DATABASE_URL")?).await?; diff --git a/examples/postgres/listen/Cargo.toml b/examples/postgres/listen/Cargo.toml index 7fa814c2..ce1d9153 100644 --- a/examples/postgres/listen/Cargo.toml +++ b/examples/postgres/listen/Cargo.toml @@ -5,6 +5,6 @@ edition = "2021" workspace = "../../../" [dependencies] -sqlx = { path = "../../../", features = [ "postgres" ] } +sqlx = { path = "../../../", features = [ "runtime-tokio", "postgres" ] } futures = "0.3.1" -tokio = { version = "1.20.0", features = ["macros"]} +tokio = { version = "1.20.0", features = ["rt-multi-thread", "macros", "time"]} diff --git a/examples/postgres/listen/src/main.rs b/examples/postgres/listen/src/main.rs index e8228d44..4d3e1db0 100644 --- a/examples/postgres/listen/src/main.rs +++ b/examples/postgres/listen/src/main.rs @@ -2,9 +2,16 @@ use futures::StreamExt; use futures::TryStreamExt; use sqlx::postgres::PgListener; use sqlx::{Executor, PgPool}; +use std::pin; +use std::pin::pin; use std::sync::atomic::{AtomicI64, Ordering}; use std::time::Duration; +/// How long to sit in the listen loop before exiting. +/// +/// This ensures the example eventually exits, which is required for automated testing. +const LISTEN_DURATION: Duration = Duration::from_secs(5); + #[tokio::main] async fn main() -> Result<(), Box> { println!("Building PG pool."); @@ -12,13 +19,16 @@ async fn main() -> Result<(), Box> { std::env::var("DATABASE_URL").expect("Env var DATABASE_URL is required for this example."); let pool = sqlx::PgPool::connect(&conn_str).await?; - let mut listener = PgListener::connect(&conn_str).await?; + let mut listener = PgListener::connect_with(&pool).await?; - // let notify_pool = pool.clone(); - let _t = async_std::task::spawn(async move { - stream::interval(Duration::from_secs(2)) - .for_each(|_| notify(&pool)) - .await + let notify_pool = pool.clone(); + let _t = tokio::spawn(async move { + let mut interval = tokio::time::interval(Duration::from_secs(2)); + + while !notify_pool.is_closed() { + interval.tick().await; + notify(¬ify_pool).await; + } }); println!("Starting LISTEN loop."); @@ -40,10 +50,28 @@ async fn main() -> Result<(), Box> { listener.execute("SELECT pg_sleep(6)").await?; let mut stream = listener.into_stream(); - while let Some(notification) = stream.try_next().await? { - println!("[from stream]: {:?}", notification); + + // `Sleep` must be pinned + let mut timeout = pin!(tokio::time::sleep(LISTEN_DURATION)); + + loop { + tokio::select! { + res = stream.try_next() => { + if let Some(notification) = res? { + println!("[from stream]: {:?}", notification); + } else { + break; + } + }, + _ = timeout.as_mut() => { + // Don't run forever + break; + } + } } + pool.close().await; + Ok(()) } diff --git a/examples/postgres/mockable-todos/Cargo.toml b/examples/postgres/mockable-todos/Cargo.toml index 58e6237f..90cf39c9 100644 --- a/examples/postgres/mockable-todos/Cargo.toml +++ b/examples/postgres/mockable-todos/Cargo.toml @@ -9,7 +9,7 @@ anyhow = "1.0" futures = "0.3" sqlx = { path = "../../../", features = ["postgres", "runtime-tokio-native-tls"] } structopt = "0.3" -tokio = { version = "1.20.0", features = ["macros"]} +tokio = { version = "1.20.0", features = ["rt", "macros"]} dotenvy = "0.15.0" async-trait = "0.1.41" mockall = "0.11" diff --git a/examples/postgres/mockable-todos/src/main.rs b/examples/postgres/mockable-todos/src/main.rs index 76db451a..89016d7d 100644 --- a/examples/postgres/mockable-todos/src/main.rs +++ b/examples/postgres/mockable-todos/src/main.rs @@ -15,7 +15,7 @@ enum Command { Done { id: i64 }, } -#[tokio::main] +#[tokio::main(flavor = "current_thread")] async fn main() -> anyhow::Result<()> { dotenvy::dotenv().ok(); let args = Args::from_args_safe()?; diff --git a/examples/postgres/todos/Cargo.toml b/examples/postgres/todos/Cargo.toml index 18f87d87..d9e3de22 100644 --- a/examples/postgres/todos/Cargo.toml +++ b/examples/postgres/todos/Cargo.toml @@ -9,5 +9,5 @@ anyhow = "1.0" futures = "0.3" sqlx = { path = "../../../", features = ["postgres", "runtime-tokio-native-tls"] } structopt = "0.3" -tokio = { version = "1.20.0", features = ["macros"]} +tokio = { version = "1.20.0", features = ["rt", "macros"]} dotenvy = "0.15.0" diff --git a/examples/postgres/todos/src/main.rs b/examples/postgres/todos/src/main.rs index 37f71415..d7400fe2 100644 --- a/examples/postgres/todos/src/main.rs +++ b/examples/postgres/todos/src/main.rs @@ -14,7 +14,7 @@ enum Command { Done { id: i64 }, } -#[tokio::main] +#[tokio::main(flavor = "current_thread")] async fn main() -> anyhow::Result<()> { let args = Args::from_args_safe()?; let pool = PgPool::connect(&env::var("DATABASE_URL")?).await?; diff --git a/examples/postgres/transaction/Cargo.toml b/examples/postgres/transaction/Cargo.toml index b0e59ef7..80ff9956 100644 --- a/examples/postgres/transaction/Cargo.toml +++ b/examples/postgres/transaction/Cargo.toml @@ -7,4 +7,4 @@ workspace = "../../../" [dependencies] sqlx = { path = "../../../", features = [ "postgres", "runtime-tokio-native-tls" ] } futures = "0.3.1" -tokio = { version = "1.20.0", features = ["macros"]} +tokio = { version = "1.20.0", features = ["rt-multi-thread", "macros"]} diff --git a/examples/postgres/transaction/src/main.rs b/examples/postgres/transaction/src/main.rs index d1fc83d5..16cdd688 100644 --- a/examples/postgres/transaction/src/main.rs +++ b/examples/postgres/transaction/src/main.rs @@ -11,12 +11,14 @@ async fn insert_and_verify( test_id, "test todo" ) - .execute(&mut *transaction) + // In 0.7, `Transaction` can no longer implement `Executor` directly, + // so it must be dereferenced to the internal connection type. + .execute(&mut **transaction) .await?; // check that inserted todo can be fetched inside the uncommitted transaction let _ = query!(r#"SELECT FROM todos WHERE id = $1"#, test_id) - .fetch_one(transaction) + .fetch_one(&mut **transaction) .await?; Ok(()) diff --git a/examples/sqlite/todos/Cargo.toml b/examples/sqlite/todos/Cargo.toml index 7084c362..90c94379 100644 --- a/examples/sqlite/todos/Cargo.toml +++ b/examples/sqlite/todos/Cargo.toml @@ -9,4 +9,4 @@ anyhow = "1.0" futures = "0.3" sqlx = { path = "../../../", features = ["sqlite", "runtime-tokio-native-tls"] } structopt = "0.3" -tokio = { version = "1.20.0", features = ["macros"]} +tokio = { version = "1.20.0", features = ["rt", "macros"]} diff --git a/examples/sqlite/todos/src/main.rs b/examples/sqlite/todos/src/main.rs index 50057d1f..a06d52e4 100644 --- a/examples/sqlite/todos/src/main.rs +++ b/examples/sqlite/todos/src/main.rs @@ -14,7 +14,7 @@ enum Command { Done { id: i64 }, } -#[tokio::main] +#[tokio::main(flavor = "current_thread")] async fn main() -> anyhow::Result<()> { let args = Args::from_args_safe()?; let pool = SqlitePool::connect(&env::var("DATABASE_URL")?).await?; @@ -53,7 +53,7 @@ VALUES ( ?1 ) "#, description ) - .execute(&mut conn) + .execute(&mut *conn) .await? .last_insert_rowid(); diff --git a/sqlx-cli/src/migrate.rs b/sqlx-cli/src/migrate.rs index 4c648e42..7e5602dd 100644 --- a/sqlx-cli/src/migrate.rs +++ b/sqlx-cli/src/migrate.rs @@ -3,6 +3,7 @@ use anyhow::{bail, Context}; use chrono::Utc; use console::style; use sqlx::migrate::{AppliedMigration, Migrate, MigrateError, MigrationType, Migrator}; +use sqlx::Connection; use std::borrow::Cow; use std::collections::{HashMap, HashSet}; use std::fmt::Write; @@ -170,6 +171,8 @@ pub async fn info(migration_source: &str, connect_opts: &ConnectOpts) -> anyhow: } } + let _ = conn.close().await; + Ok(()) } @@ -249,6 +252,13 @@ pub async fn run( } } + // Close the connection before exiting: + // * For MySQL and Postgres this should ensure timely cleanup on the server side, + // including decrementing the open connection count. + // * For SQLite this should checkpoint and delete the WAL file to ensure the migrations + // were actually applied to the database file and aren't just sitting in the WAL file. + let _ = conn.close().await; + Ok(()) } @@ -310,6 +320,8 @@ pub async fn revert( println!("No migrations available to revert"); } + let _ = conn.close().await; + Ok(()) } diff --git a/sqlx-core/Cargo.toml b/sqlx-core/Cargo.toml index 51884882..fcb3e1fa 100644 --- a/sqlx-core/Cargo.toml +++ b/sqlx-core/Cargo.toml @@ -8,7 +8,7 @@ authors.workspace = true repository.workspace = true [package.metadata.docs.rs] -features = ["offline", "runtime-tokio-native-tls"] +features = ["offline"] [features] default = [] @@ -93,5 +93,5 @@ event-listener = "2.5.2" dotenvy = "0.15" [dev-dependencies] -sqlx = { workspace = true, features = ["postgres", "sqlite", "mysql", "migrate"] } +sqlx = { workspace = true, features = ["postgres", "sqlite", "mysql", "migrate", "macros"] } tokio = { version = "1", features = ["rt"] } diff --git a/sqlx-macros-core/Cargo.toml b/sqlx-macros-core/Cargo.toml index e7a76f60..48e8d264 100644 --- a/sqlx-macros-core/Cargo.toml +++ b/sqlx-macros-core/Cargo.toml @@ -8,6 +8,8 @@ authors.workspace = true repository.workspace = true [features] +default = [] + # for conditional compilation _rt-async-std = ["async-std", "sqlx-core/_rt-async-std"] _rt-tokio = ["tokio", "sqlx-core/_rt-tokio"] @@ -36,7 +38,7 @@ time = ["sqlx-core/time", "sqlx-mysql?/time", "sqlx-postgres?/time", "sqlx-sqlit uuid = ["sqlx-core/uuid", "sqlx-mysql?/uuid", "sqlx-postgres?/uuid", "sqlx-sqlite?/uuid"] [dependencies] -sqlx-core = { workspace = true, default-features = false, features = ["offline"] } +sqlx-core = { workspace = true, features = ["offline"] } sqlx-mysql = { workspace = true, features = ["offline", "migrate"], optional = true } sqlx-postgres = { workspace = true, features = ["offline", "migrate"], optional = true } sqlx-sqlite = { workspace = true, features = ["offline", "migrate"], optional = true } diff --git a/sqlx-macros/Cargo.toml b/sqlx-macros/Cargo.toml index f96e6f84..82fecab7 100644 --- a/sqlx-macros/Cargo.toml +++ b/sqlx-macros/Cargo.toml @@ -11,6 +11,7 @@ repository.workspace = true proc-macro = true [features] +default = [] # for conditional compilation _rt-async-std = ["sqlx-macros-core/_rt-async-std"] @@ -39,7 +40,7 @@ uuid = ["sqlx-macros-core/uuid"] json = ["sqlx-macros-core/json"] [dependencies] -sqlx-core = { workspace = true, default-features = false, features = ["any"] } +sqlx-core = { workspace = true, features = ["any"] } sqlx-macros-core = { workspace = true } proc-macro2 = { version = "1.0.36", default-features = false } diff --git a/sqlx-sqlite/src/options/connect.rs b/sqlx-sqlite/src/options/connect.rs index 3b4b5313..daca2d06 100644 --- a/sqlx-sqlite/src/options/connect.rs +++ b/sqlx-sqlite/src/options/connect.rs @@ -5,6 +5,7 @@ use sqlx_core::connection::ConnectOptions; use sqlx_core::error::Error; use sqlx_core::executor::Executor; use std::fmt::Write; +use std::str::FromStr; use std::time::Duration; use url::Url; @@ -12,7 +13,15 @@ impl ConnectOptions for SqliteConnectOptions { type Connection = SqliteConnection; fn from_url(url: &Url) -> Result { - Self::from_db_and_params(url.path(), url.query()) + // SQLite URL parsing is handled specially; + // we want to treat the following URLs as equivalent: + // + // * sqlite:foo.db + // * sqlite://foo.db + // + // If we used `Url::path()`, the latter would return an empty string + // because `foo.db` gets parsed as the hostname. + Self::from_str(url.as_str()) } fn connect(&self) -> BoxFuture<'_, Result>