130 Commits

Author SHA1 Message Date
iamjpotts
5d4e1a4d4d
chore(deps): Set default-features=false on sqlx in workspace.dependencies (#3989)
Signed-off-by: Joshua Potts <8704475+iamjpotts@users.noreply.github.com>
2025-08-27 11:02:27 -07:00
João Sampaio
5f8fc6b752
Pool.close: close all connections before returning (#3952)
* fix race condition in pool close (#3217)

* fix deadlock in the postgres/listen example

* Only acquire as many permits as a child pool can offer

---------

Co-authored-by: Adam Cigánek <adam.ciganek@proton.me>
2025-08-15 17:20:51 -07:00
Austin Bonander
21598cfec6
breaking(sqlite): libsqlite3-sys versioning, feature flags, safety changes (#3928) 2025-07-17 01:13:32 -07:00
djarb
f7ef1ed1e9
feat(sqlx.toml): support SQLite extensions in macros and sqlx-cli (#3917)
* feat: create `sqlx.toml` format

* feat: add support for ignored_chars config to sqlx_core::migrate

* chore: test ignored_chars with `U+FEFF` (ZWNBSP/BOM)

https://en.wikipedia.org/wiki/Byte_order_mark

* refactor: make `Config` always compiled

simplifies usage while still making parsing optional for less generated code

* refactor: add origin information to `Column`

* feat(macros): implement `type_override` and `column_override` from `sqlx.toml`

* refactor(sqlx.toml): make all keys kebab-case, create `macros.preferred-crates`

* feat: make macros aware of `macros.preferred-crates`

* feat: make `sqlx-cli` aware of `database-url-var`

* feat: teach macros about `migrate.table-name`, `migrations-dir`

* feat: teach macros about `migrate.ignored-chars`

* feat: teach `sqlx-cli` about `migrate.defaults`

* feat: teach `sqlx-cli` about `migrate.migrations-dir`

* feat: teach `sqlx-cli` about `migrate.table-name`

* feat: introduce `migrate.create-schemas`

* WIP feat: create multi-tenant database example

* SQLite extension loading via sqlx.toml for CLI and query macros

* fix: allow start_database to function when the SQLite database file does not already exist

* Added example demonstrating migration and compile-time checking with SQLite extensions

* remove accidentally included db file

* Update sqlx-core/src/config/common.rs

Doc formatting tweak

Co-authored-by: Josh McKinney <joshka@users.noreply.github.com>

* feat: create `sqlx.toml` format

* feat: add support for ignored_chars config to sqlx_core::migrate

* chore: test ignored_chars with `U+FEFF` (ZWNBSP/BOM)

https://en.wikipedia.org/wiki/Byte_order_mark

* refactor: make `Config` always compiled

simplifies usage while still making parsing optional for less generated code

* refactor: add origin information to `Column`

* feat(macros): implement `type_override` and `column_override` from `sqlx.toml`

* refactor(sqlx.toml): make all keys kebab-case, create `macros.preferred-crates`

* feat: make macros aware of `macros.preferred-crates`

* feat: make `sqlx-cli` aware of `database-url-var`

* feat: teach macros about `migrate.table-name`, `migrations-dir`

* feat: teach macros about `migrate.ignored-chars`

* feat: teach `sqlx-cli` about `migrate.defaults`

* feat: teach `sqlx-cli` about `migrate.migrations-dir`

* feat: teach `sqlx-cli` about `migrate.table-name`

* feat: introduce `migrate.create-schemas`

* fix(postgres): don't fetch `ColumnOrigin` for transparently-prepared statements

* feat: progress on axum-multi-tenant example

* feat(config): better errors for mislabeled fields

* WIP feat: filling out axum-multi-tenant example

* feat: multi-tenant example

No longer Axum-based because filling out the request routes would have distracted from the purpose of the example.

* chore(ci): test multi-tenant example

* fixup after merge

* fix: CI, README for `multi-tenant`

* fix: clippy warnings

* fix: multi-tenant README

* fix: sequential versioning inference for migrations

* fix: migration versioning with explicit overrides

* fix: only warn on ambiguous crates if the invocation relies on it

* fix: remove unused imports

* fix: `sqlx mig add` behavior and tests

* fix: restore original type-checking order

* fix: deprecation warning in `tests/postgres/macros.rs`

* feat: create postgres/multi-database example

* fix: examples/postgres/multi-database

* fix: cargo fmt

* chore: add tests for config `migrate.defaults`

* fix: sqlx-cli/tests/add.rs

* feat(cli): add `--config` override to all relevant commands

* chore: run `sqlx mig add` test with `RUST_BACKTRACE=1`

* fix: properly canonicalize config path for `sqlx mig add` test

* fix: get `sqlx mig add` test passing

* fix(cli): test `migrate.ignored-chars`, fix bugs

* feat: create `macros.preferred-crates` example

* fix(examples): use workspace `sqlx`

* fix: examples

* fix: run `cargo fmt`

* fix: more example fixes

* fix(ci): preferred-crates setup

* fix: axum-multi-tenant example locked to specific sqlx version

* import anyhow::Context trait in sqlx-cli/src/lib.rs since it was being used and causing a compile error

* rebased on upstream/main

* make cargo fmt happy

* make clippy happy

* make clippy happier still

* fix: improved error reporting, added parsing test, removed sqlx-toml flag use

* switched to kebab-case for the config key

* switched to kebab-case for the config key

---------

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
Co-authored-by: Josh McKinney <joshka@users.noreply.github.com>
2025-07-08 01:20:46 -07:00
Austin Bonander
25cbeedab4
feat: create sqlx.toml format (#3383)
* feat: create `sqlx.toml` format

* feat: add support for ignored_chars config to sqlx_core::migrate

* chore: test ignored_chars with `U+FEFF` (ZWNBSP/BOM)

https://en.wikipedia.org/wiki/Byte_order_mark

* refactor: make `Config` always compiled

simplifies usage while still making parsing optional for less generated code

* refactor: add origin information to `Column`

* feat(macros): implement `type_override` and `column_override` from `sqlx.toml`

* refactor(sqlx.toml): make all keys kebab-case, create `macros.preferred-crates`

* feat: make macros aware of `macros.preferred-crates`

* feat: make `sqlx-cli` aware of `database-url-var`

* feat: teach macros about `migrate.table-name`, `migrations-dir`

* feat: teach macros about `migrate.ignored-chars`

* chore: delete unused source file `sqlx-cli/src/migration.rs`

* feat: teach `sqlx-cli` about `migrate.defaults`

* feat: teach `sqlx-cli` about `migrate.migrations-dir`

* feat: teach `sqlx-cli` about `migrate.table-name`

* feat: introduce `migrate.create-schemas`

* WIP feat: create multi-tenant database example

* fix(postgres): don't fetch `ColumnOrigin` for transparently-prepared statements

* feat: progress on axum-multi-tenant example

* feat(config): better errors for mislabeled fields

* WIP feat: filling out axum-multi-tenant example

* feat: multi-tenant example

No longer Axum-based because filling out the request routes would have distracted from the purpose of the example.

* chore(ci): test multi-tenant example

* fixup after merge

* fix(ci): enable `sqlx-toml` in CLI build for examples

* fix: CI, README for `multi-tenant`

* fix: clippy warnings

* fix: multi-tenant README

* fix: sequential versioning inference for migrations

* fix: migration versioning with explicit overrides

* fix: only warn on ambiguous crates if the invocation relies on it

* fix: remove unused imports

* fix: doctest

* fix: `sqlx mig add` behavior and tests

* fix: restore original type-checking order

* fix: deprecation warning in `tests/postgres/macros.rs`

* feat: create postgres/multi-database example

* fix: examples/postgres/multi-database

* fix: cargo fmt

* chore: add tests for config `migrate.defaults`

* fix: sqlx-cli/tests/add.rs

* feat(cli): add `--config` override to all relevant commands

* chore: run `sqlx mig add` test with `RUST_BACKTRACE=1`

* fix: properly canonicalize config path for `sqlx mig add` test

* fix: get `sqlx mig add` test passing

* fix(cli): test `migrate.ignored-chars`, fix bugs

* feat: create `macros.preferred-crates` example

* fix(examples): use workspace `sqlx`

* fix: examples

* fix(sqlite): unexpected feature flags in `type_checking.rs`

* fix: run `cargo fmt`

* fix: more example fixes

* fix(ci): preferred-crates setup

* fix(examples): enable default-features for workspace `sqlx`

* fix(examples): issues in `preferred-crates`

* chore: adjust error message for missing param type in `query!()`

* doc: mention new `sqlx.toml` configuration

* chore: add `CHANGELOG` entry

Normally I generate these when cutting the release, but I wanted to take time to editorialize this one.

* doc: fix new example titles

* refactor: make `sqlx-toml` feature non-default, improve errors

* refactor: eliminate panics in `Config` read path

* chore: remove unused `axum` dependency from new examples

* fix(config): restore fallback to default config for macros

* chore(config): remove use of `once_cell` (to match `main`)
2025-06-30 16:34:46 -07:00
Paolo Barbolini
764ae2f702
chore: replace once_cell OnceCell/Lazy with std OnceLock/LazyLock (#3709) 2025-06-17 16:38:02 -07:00
Paolo Barbolini
df47ffedd2
Replace some more futures_util APIs with std variants (#3874) 2025-06-15 15:18:39 -07:00
Austin Bonander
90797200ee
groundwork for 0.9.0-alpha.1 (#3821)
* chore: bump version to `0.9.0-alpha.1`

* chore: delete unused `sqlx-bench` package

* chore: set `rust-version` to 1.85 for all crates

* fix: lots of new Clippy warnings

* fix: lots more Clippy warnings

* fix(cli): add `_sqlite` feature

* fix: lots, *lots* more Clippy warnings

* fix(core): warning in `tls_rustls`

* breaking: delete runtime+TLS combination features

* chore: don't re-export unstable `TransactionManager` trait

* chore: 0.9.0-alplha.1 CHANGELOG

* chore: increase MSRV further to 1.86

* fix: more clippy warnings
2025-06-01 21:09:55 -07:00
Paolo Barbolini
3e8952b0d4
Bump thiserror to v2.0.0 (#3596) 2024-11-26 11:01:33 -08:00
carschandler
8a17bef7d7
Remove deprecated feature-names from Cargo.toml files in examples (#3424) 2024-08-26 14:03:45 -07:00
Frank Elsinga
fd4cb99fc7
chore(examples):Migrated the pg-chat example to ratatui (#3385)
* migrated the pg-chat example to ratatui

* fixed formatting mistake
2024-07-29 04:35:27 -07:00
tottoto
4ce181f869
chore: replace structopt with clap in examples (#3380) 2024-07-27 02:51:20 -07:00
Joshua Potts
ba1b2f9b82 refactor: Resolve cargo check warnings in postgres examples
Signed-off-by: Joshua Potts <8704475+iamjpotts@users.noreply.github.com>
2024-07-10 22:15:31 -07:00
Yuri Astrakhan
a824e8468c
Cleanup format arguments (#2650)
Inlined format args make code more readable, and code more compact.

I ran this clippy command to fix most cases, and then cleaned up a few trailing commas and uncaught edge cases.

```
cargo clippy --bins --examples  --benches --tests --lib --workspace --fix -- -A clippy::all -W clippy::uninlined_format_args
```
2023-07-31 13:27:04 -07:00
Joakim Malmberg
8cad54cc9f
Add postgres chat exmaple (#2577)
Co-authored-by: Stephen <webmaster@scd31.com>
2023-07-24 16:09:06 -07:00
Austin Bonander
dcb58b0e2c
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
2023-07-03 14:37:37 -07:00
Austin Bonander
b5312c3b6f Break drivers out into separate crates, clean up some technical debt (#2039)
* WIP rt refactors

* refactor: break drivers out into separate crates

also cleans up significant technical debt
2023-02-21 13:25:25 -08:00
Austin Bonander
b6cddcd014
prepare 0.6.2 release (#2092) 2022-09-14 15:23:06 -07:00
Austin Bonander
cb52c7c62b chore: prep 0.6.1 release 2022-08-02 19:16:32 -07:00
Austin Bonander
054f61980a
feat: implement testing utilities (#2001) 2022-08-02 14:38:12 -07:00
Austin Bonander
a2eceec33b
chore: replace dotenv with dotenvy (#2003)
* chore: replace `dotenv` with `dotenvy`

The former appears to be unmaintained and the latter is a drop-in replacement.

* chore: fix all warnings
2022-07-28 14:33:44 -07:00
Marco Neumann
05d64fb722
fix: agree one a single default runtime for the whole workspace (#1988)
This fixes `cargo check --workspace` and rust-analyzer.

Also see <https://github.com/launchbadge/sqlx/discussions/1956>.
2022-07-28 13:15:40 -07:00
Joey McKenzie
d6c4eff81a
Add example with external query files (#1967)
* feat(examples): add files example for postgres

* fix(examples): add missing deps
2022-07-13 14:45:34 -07:00
Paolo Barbolini
b934f82440
Bump remanining dependencies (#1807)
Co-authored-by: Austin Bonander <austin@launchbadge.com>
2022-04-15 14:34:48 -07:00
Paolo Barbolini
fc9c9be5e8
Update to edition 2021 (#1808)
* Update to edition 2021

* Fix running tests
2022-04-15 12:52:00 -07:00
Matthias Hörmann
fd4d219c66
fix and extend postgres transaction example (#1636) 2022-02-16 19:05:31 -08:00
Rafael Epplée
e77219f7c7
Add docs for fetch_all, example for postgres transactions (#1255)
* reference fetch_all() in query macros

* add example for using transactions in postgres
2021-08-16 16:33:42 -07:00
Jonas Platte
901f858fbc
sqlx-data.json removal prep work (#1184)
* macros: Reduce I/O

by doing all .env and environment variable reading inside a Lazy initializer.

* Use the default runtime and TLS backend for all examples

Before, rust-analyzer was always hitting the
"only one runtime can be enabled" compile_error in sqlx-rt.
2021-05-21 17:33:56 -07:00
Jonas Platte
c5d43db312
Upgrade async runtime dependencies
Co-authored-by: Josh Toft <joshtoft@gmail.com>
Co-authored-by: Philip A Reimer <antreimer@gmail.com>
2021-01-20 21:50:45 -08:00
Jonas Platte
a1d562f04b
Remove the Done trait 2021-01-12 14:37:44 +01:00
Mike Cronce
ff05ad9a10 examples/mysql/todos/Cargo.toml: Add runtime feature 2020-12-19 07:17:55 +00:00
Matt Paul
33521d6b74 Add docker-compose and .env 2020-12-19 05:31:21 +00:00
Matt Paul
b5504b27cd Update readme 2020-12-19 05:31:21 +00:00
Matt Paul
0b45dd9e3f Write test 2020-12-19 05:31:21 +00:00
Matt Paul
a5cede500e Implement TodoRepo trait 2020-12-19 05:31:21 +00:00
Matt Paul
bc4c3bc066 Extract postgres todo repo struct 2020-12-19 05:31:21 +00:00
Matt Paul
6f363cf4ea Make mockable-todos example compile 2020-12-19 05:31:21 +00:00
Matt Paul
7510316eb6 Make todos example compile 2020-12-19 05:31:21 +00:00
Matt Paul
da178405b9 Copy 'todos' example directory as starting point 2020-12-19 05:31:21 +00:00
Raphaël Thériault
04f68632b4 JSON+macros example using overrides 2020-11-12 07:21:54 -08:00
Austin Bonander
685d70ba62 refactor(examples): use select pg_notify in postgres/listen
Signed-off-by: Austin Bonander <austin@launchbadge.com>
2020-07-28 03:21:19 -07:00
Ryan Leckey
4857d051e1 chore: update listener example 2020-07-27 02:22:59 -07:00
Ryan Leckey
d04d612368 Remove realworld example.
I'd prefer to have one but I'd rather not have one then one that doesn't compile.

Ideally someone could take up maintaining a realworld example outside of SQLx. Until GATs though we
should keep this to one database. Looking back, most of the reason this is so hard to migrate to 0.4 is
because of how generic the bounds are.
2020-07-27 02:22:31 -07:00
Ryan Leckey
f66025b460 remove examples/postgres/todo-api as there is now a similar example in actix/examples 2020-07-27 02:12:11 -07:00
Ryan Leckey
96b76dc737 update todo examples to 0.4 and use migrations
* update tests/x.py

 * add examples/x.py
2020-07-18 05:43:16 -07:00
Ryan Leckey
fc682fa991 fix: adjust pool usage in tests and examples 2020-07-12 04:42:48 -07:00
Ryan Leckey
f0e79979dd fix: remove XQueryAs imports (gone in 0.4) 2020-06-27 06:02:14 -07:00
rage311
a0d1106f90 Added quotes to listen/unlisten channel names to honor case sensitivity and be consistent with 'listen_all()' 2020-06-05 19:50:44 -07:00
Ryan Leckey
9d2a0141cb
feat: introduce IntoArguments, query_with, query_as_with, and query_scalar_with 2020-05-30 17:51:55 -07:00
Austin Bonander
6b248e0d5f get offline macros working with todos example 2020-05-30 16:02:37 -07:00