2679 Commits

Author SHA1 Message Date
Austin Bonander
febc62aaab feat: create postgres/jiff-sqlx example 2025-04-11 21:27:12 -07:00
Austin Bonander
db6d28bfb1 feat: create postgres/multi-database example 2025-04-10 19:39:07 -07:00
Austin Bonander
b989b366c2 fix: deprecation warning in tests/postgres/macros.rs 2025-03-31 03:09:47 -07:00
Austin Bonander
80abc5b166 fix: restore original type-checking order 2025-03-31 01:54:12 -07:00
Austin Bonander
52bb9d0f21 fix: sqlx mig add behavior and tests 2025-03-30 23:33:07 -07:00
Austin Bonander
1eb0f499b7 fix: doctest 2025-03-30 19:21:19 -07:00
Austin Bonander
0a32d01081 fix: remove unused imports 2025-03-30 14:35:57 -07:00
Austin Bonander
732233a5da fix: only warn on ambiguous crates if the invocation relies on it 2025-03-30 03:42:28 -07:00
Austin Bonander
4e95bafb35 Merge remote-tracking branch 'origin/main' into sqlx-toml
# Conflicts:
#	.github/workflows/examples.yml
#	sqlx-postgres/src/connection/mod.rs
2025-03-29 15:57:39 -07:00
Beau Gieskens
1c9cbe939a
feat: add ipnet support (#3710)
* feat: add ipnet support

* fix: ipnet not decoding IP address strings

* fix: prefer ipnetwork to ipnet for compatibility

* fix: unnecessary cfg
2025-03-23 17:19:05 -07:00
Robin Schroer
e474be6d4b
docs: Fix a copy-paste error on get_username docs (#3786)
I suspect this is a copy-paste error, it's meant to say username, not port.
2025-03-15 23:21:56 -07:00
Austin Bonander
393b731d5e
Merge of #3427 (by @mpyw) and #3614 (by @bonsairobo) (#3765)
* feat: Implement `get_transaction_depth` for drivers

* test: Verify `get_transaction_depth()` on postgres

* Refactor: `TransactionManager` delegation without BC

SQLite implementation is currently WIP

* Fix: Avoid breaking changes on `AnyConnectionBackend`

* Refactor: Remove verbose `SqliteConnection` typing

* Feat: Implementation for SQLite

I have included `AtomicUsize` in `WorkerSharedState`. Ideally, it is not desirable to execute `load` and `fetch_add` in two separate steps, but we decided to allow it here since there is only one thread writing. To prevent writing from other threads, the field itself was made private, and a getter method was provided with `pub(crate)`.

* Refactor: Same approach for `cached_statements_size`

ref: a66787d36d62876b55475ef2326d17bade817aed

* Fix: Add missing `is_in_transaction` for backend

* Doc: Remove verbose "synchronously" word

* Fix: Remove useless `mut` qualifier

* feat: add Connection::begin_with

This patch completes the plumbing of an optional statement from these methods to
`TransactionManager::begin` without any validation of the provided statement.

There is a new `Error::InvalidSavePoint` which is triggered by any attempt to
call `Connection::begin_with` when we are already inside of a transaction.

* feat: add Pool::begin_with and Pool::try_begin_with

* feat: add Error::BeginFailed and validate that custom "begin" statements are successful

* chore: add tests of Error::BeginFailed

* chore: add tests of Error::InvalidSavePointStatement

* chore: test begin_with works for all SQLite "BEGIN" statements

* chore: improve comment on Connection::begin_with

* feat: add default impl of `Connection::begin_with`

This makes the new method a non-breaking change.

* refactor: combine if statement + unwrap_or_else into one match

* feat: use in-memory SQLite DB to avoid conflicts across tests run in parallel

* feedback: remove public wrapper for sqlite3_txn_state

Move the wrapper directly into the test that uses it instead.

* fix: cache Status on MySqlConnection

* fix: compilation errors

* fix: format

* fix: postgres test

* refactor: delete `Connection::get_transaction_depth`

* fix: tests

---------

Co-authored-by: mpyw <ryosuke_i_628@yahoo.co.jp>
Co-authored-by: Duncan Fairbanks <duncanfairbanks6@gmail.com>
2025-03-10 14:29:46 -07:00
James H.
2f10c29dfd
feat(postgres): add geometry circle (#3773)
* feat: circle

* docs: comments
2025-03-09 15:01:30 -07:00
James H.
ca3a509036
feat(postgres): add geometry polygon (#3769)
* feat: add polygon

* test: paths for pgpoints in polygon test

* fix: import typo

* chore(Sqlite): remove ci.db from repo (#3768)

* fix: CI

* Fix breakage from Rustup 1.28 <https://blog.rust-lang.org/2025/03/02/Rustup-1.28.0.html>
* Let `Swatinem/rust-cache` generate cache keys

* fix(ci): upgrade Ubuntu image to 24.04

For some reason the `cargo +beta clippy` step is failing because `libsqlite3-sys` starts requiring Glibc >= 2.39 but I don't have time to figure out why and I can't reproduce it in a clean environment.

---------

Co-authored-by: joeydewaal <99046430+joeydewaal@users.noreply.github.com>
Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
2025-03-07 01:25:45 -08:00
Chitoku
a92626d6cc postgres: Use current tracing span when dropping PgListener 2025-03-05 01:30:38 -08:00
Austin Bonander
c3fd645409 fix(ci): upgrade Ubuntu image to 24.04
For some reason the `cargo +beta clippy` step is failing because `libsqlite3-sys` starts requiring Glibc >= 2.39 but I don't have time to figure out why and I can't reproduce it in a clean environment.
2025-03-04 14:31:38 -08:00
Austin Bonander
7a2a94e7b5 fix: CI
* Fix breakage from Rustup 1.28 <https://blog.rust-lang.org/2025/03/02/Rustup-1.28.0.html>
* Let `Swatinem/rust-cache` generate cache keys
2025-03-04 14:31:38 -08:00
joeydewaal
7af998c2ab
chore(Sqlite): remove ci.db from repo (#3768) 2025-03-04 12:56:08 -08:00
James H.
5c573e15eb
feat(postgres): add geometry path (#3716)
* feat: add geometry path

* fix: paths to pg point

* test: remove array tests for path

* Fix readme: uuid feature is gating for all repos (#3720)

The readme previously stated that the uuid feature is only for postres but it actually also gates the functionality in mysql and sqlite.

* Replace some futures_util APIs with std variants (#3721)

* feat(sqlx-cli): Add flag to disable automatic loading of .env files (#3724)

* Add flag to disable automatic loading of .env files

* Update sqlx-cli/src/opt.rs

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>

---------

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>

* chore: expose bstr feature (#3714)

* chore: replace rustls-pemfile with rustls-pki-types (#3725)

* QueryBuilder: add `debug_assert` when `push_values` is passed an empty set of tuples (#3734)

* throw a warning in tracing so that the empty tuples would be noticed

* use debug assertion to throw a panic in debug mode

* fix: merge conflicts

* chore(cli): remove unused async-trait crate from dependencies (#3754)

* Update pull_request_template.md

* Fix example calculation (#3741)

* Avoid privilege requirements by using an advisory lock in test setup (postgres). (#3753)

* feat(sqlx-postgres): use advisory lock to avoid setup race condition

* fix(sqlx-postgres): numeric hex constants not supported before postgres 16

* Small doc correction. (#3755)

When sqlx-core/src/from_row.rs was updated to implement FromRow for tuples of up to 16 values, a comment was left stating that it was implemented up to tuples of 9 values.

* Update FAQ.md

* refactor(cli): replace promptly with dialoguer (#3669)

* docs(pool): recommend actix-web ThinData over Data to avoid two Arcs (#3762)

Both actix_web::web::Data and sqlx::PgPool internally wrap an Arc. Thus,
using Data<PgPool> as an extractor in an actix-web route handler results
in two Arcs wrapping the data of interest, which isn't ideal.

Actix-web 4.9.0 introduced a new web::ThinData extractor for cases like
this, where the data is already wrapped in an `Arc` (or is otherwise
similarly cheap and sensible to simply clone), which doesn't wrap the
inner value in a (second) Arc.

Since the new extractor is better suited to the task, suggest it in
place of web::Data when giving an example on how to share a pool.

* fix: merge conflicts

* fix: use types mod from main

* fix: merge conflicts

* fix: merge conflicts

* fix: merge conflicts

* fix: ordering of types mod

* fix: path import

* test: no array test for path

---------

Co-authored-by: Jon Thacker <thacker.jon@gmail.com>
Co-authored-by: Paolo Barbolini <paolo.barbolini@m4ss.net>
Co-authored-by: Ben Wilber <benwilber@users.noreply.github.com>
Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
Co-authored-by: joeydewaal <99046430+joeydewaal@users.noreply.github.com>
Co-authored-by: tottoto <tottotodev@gmail.com>
Co-authored-by: Ethan Wang <mailme@ethanavania.org>
Co-authored-by: Stefan Schindler <dns2utf8@users.noreply.github.com>
Co-authored-by: kildrens <5198060+kildrens@users.noreply.github.com>
Co-authored-by: Marti Serra <marti.serra+github@protonmail.com>
Co-authored-by: Jonas Malaco <jonas@protocubo.io>
2025-03-02 14:29:53 -08:00
Mattia Righetti
c5ea6c4435
feat: sqlx sqlite expose de/serialize (#3745)
* feat: implement serialze no copy on lockedsqlitehandle

* feat: implement serialize on sqliteconnection

* feat: implement deserialize on sqliteconnection and add sqlitebuf wrapper type

* refactor: misc sqlite type and deserialize refactoring

* chore: misc clippy refactoring

* fix: misc refactoring and fixes

- pass non-owned byte slice to deserialize
- `SqliteBufError` and better error handling
- more impl for `SqliteOnwedBuf` so it can be used as a slice
- default serialize for `SqliteConnection`

* refactor: move serialize and deserialize on worker thread

This implements `Command::Serialize` and `Command::Deserialize` and moves the
serialize and deserialize logic to the worker thread.

`Serialize` will need some more iterations as it's not clear whether it would
need to wait for other write transactions before running.

* refactor: misc refactoring and changes

- Merged deserialize module with serialize module
- Moved `SqliteOwnedBuf` into serialize module
- Fixed rustdocs

* chore: API tweaks, better docs, tests

* fix: unused import

* fix: export `SqliteOwnedBuf`, docs and safety tweaks

---------

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
2025-03-02 14:29:29 -08:00
Jonas Malaco
5d6d6985cd
docs(pool): recommend actix-web ThinData over Data to avoid two Arcs (#3762)
Both actix_web::web::Data and sqlx::PgPool internally wrap an Arc. Thus,
using Data<PgPool> as an extractor in an actix-web route handler results
in two Arcs wrapping the data of interest, which isn't ideal.

Actix-web 4.9.0 introduced a new web::ThinData extractor for cases like
this, where the data is already wrapped in an `Arc` (or is otherwise
similarly cheap and sensible to simply clone), which doesn't wrap the
inner value in a (second) Arc.

Since the new extractor is better suited to the task, suggest it in
place of web::Data when giving an example on how to share a pool.
2025-02-28 16:42:53 -08:00
Austin Bonander
8ddcd0640e fix: migration versioning with explicit overrides 2025-02-27 18:41:47 -08:00
Austin Bonander
ac7f270932 fix: sequential versioning inference for migrations 2025-02-27 18:30:43 -08:00
Austin Bonander
a9a4d00a80 fix: multi-tenant README 2025-02-27 18:17:40 -08:00
Austin Bonander
2b6915000c fix: clippy warnings 2025-02-27 18:16:09 -08:00
Austin Bonander
4fb7102cb2 fix: CI, README for multi-tenant 2025-02-27 17:27:57 -08:00
Austin Bonander
15df1593c6 fix(ci): enable sqlx-toml in CLI build for examples 2025-02-27 17:22:39 -08:00
Austin Bonander
f4d22fb008 fixup after merge 2025-02-27 17:10:23 -08:00
Austin Bonander
8429f2e989 Merge remote-tracking branch 'origin/main' into sqlx-toml
# Conflicts:
#	Cargo.lock
#	Cargo.toml
#	sqlx-cli/src/database.rs
#	sqlx-cli/src/lib.rs
#	sqlx-mysql/src/connection/executor.rs
2025-02-27 17:04:34 -08:00
Austin Bonander
1b0c64a9e9 chore(ci): test multi-tenant example 2025-02-27 17:00:37 -08:00
Austin Bonander
46878e8c0b feat: multi-tenant example
No longer Axum-based because filling out the request routes would have distracted from the purpose of the example.
2025-02-27 16:20:09 -08:00
Paolo Barbolini
277dd36c78
refactor(cli): replace promptly with dialoguer (#3669) 2025-02-27 12:17:09 -08:00
Austin Bonander
0b79b51d74 WIP feat: filling out axum-multi-tenant example 2025-02-26 13:36:53 -08:00
Austin Bonander
9bd3d61929
Update FAQ.md 2025-02-22 18:07:43 -08:00
Marti Serra
3dec1d186a
Small doc correction. (#3755)
When sqlx-core/src/from_row.rs was updated to implement FromRow for tuples of up to 16 values, a comment was left stating that it was implemented up to tuples of 9 values.
2025-02-22 13:33:14 -08:00
Austin Bonander
d9fc4899ad feat(config): better errors for mislabeled fields 2025-02-21 15:52:27 -08:00
kildrens
a9dfb4f2c1
Avoid privilege requirements by using an advisory lock in test setup (postgres). (#3753)
* feat(sqlx-postgres): use advisory lock to avoid setup race condition

* fix(sqlx-postgres): numeric hex constants not supported before postgres 16
2025-02-20 18:13:56 -08:00
Stefan Schindler
8dce6bd9e1
Fix example calculation (#3741) 2025-02-20 12:57:54 -08:00
Austin Bonander
26b4e5f166
Update pull_request_template.md 2025-02-20 12:51:54 -08:00
tottoto
520d25c453
chore(cli): remove unused async-trait crate from dependencies (#3754) 2025-02-20 11:35:44 -08:00
Sam Lyon
8cdad44366
docs: add some missing backticks (#3749)
* add ending backticks to starting backticks that were missing them

* fix table alignment
2025-02-19 15:23:45 -08:00
Ethan Wang
b859914153
QueryBuilder: add debug_assert when push_values is passed an empty set of tuples (#3734)
* throw a warning in tracing so that the empty tuples would be noticed

* use debug assertion to throw a panic in debug mode
2025-02-17 17:39:40 -08:00
tottoto
3a20a92a3f
chore: replace rustls-pemfile with rustls-pki-types (#3725) 2025-02-05 13:48:19 -08:00
joeydewaal
f42561b8d7
chore: expose bstr feature (#3714) 2025-02-04 10:53:05 -08:00
Ben Wilber
91291beb23
feat(sqlx-cli): Add flag to disable automatic loading of .env files (#3724)
* Add flag to disable automatic loading of .env files

* Update sqlx-cli/src/opt.rs

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>

---------

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
2025-02-04 10:52:43 -08:00
Austin Bonander
c2b9f87e31 feat: progress on axum-multi-tenant example 2025-02-01 23:53:23 -08:00
Austin Bonander
7d646a9251 fix(postgres): don't fetch ColumnOrigin for transparently-prepared statements 2025-02-01 23:42:51 -08:00
Paolo Barbolini
65229f7ff9
Replace some futures_util APIs with std variants (#3721) 2025-02-01 16:01:56 -08:00
Jon Thacker
5b26369a59
Fix readme: uuid feature is gating for all repos (#3720)
The readme previously stated that the uuid feature is only for postres but it actually also gates the functionality in mysql and sqlite.
2025-01-31 15:22:47 -08:00
Tobias Bieniek
4d638c9e24
FromRow: Fix documentation order (#3712)
The `try_from` and `json` sections are "Field attributes" so they should probably be part of the corresponding section instead of subsections of "Manual implementation". `flatten` should be H4 instead of H3, since "Field attributes" is H3 and all other field attribute sections are H4 too.
2025-01-29 15:00:21 -08:00