Commit graph

1067 commits

Author SHA1 Message Date
Hannes Körber
35ba8e2b93
docs: Fix description of min_connections (#2687)
On `PoolOptions::connect()`, we open at least `min_connections`
connections, or 1 if unset. Therefore, the expression needs to be
`max()`. (`min(1, x)` would mean we always open only a single
connection).
2023-09-11 19:28:54 -07:00
Bogdan Mircea
745486b485
Remove sealed trait comments from documentation (#2740)
* Fix Row trait docs as it isn't sealed anymore

* Fix ColumnIndex trait docs as it isn't sealed anymore
2023-09-11 19:03:02 -07:00
Bogdan Mircea
4d12ca4e1d
Implemented poll_flush for Box<S:Socket> (#2742) 2023-09-11 19:02:38 -07:00
Edwin
2e4533eb32
remove &mut PoolConnection from docs (#2695) 2023-09-11 18:38:43 -07:00
Austin Bonander
2497f0bdc8 fix: run cargo fmt with latest Rust 2023-09-11 18:06:16 -07:00
Max Vorobev
d0fbe7feff
Automatically infer migration type (#2664) 2023-08-01 11:16:43 -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
Marco Cameriero
9463b7592f
Add JSON support to FromRow derive (#2121)
* Add `json` attribute to `FromRow` derive

* Add docs and fix formatting
2023-07-31 12:52:42 -07:00
Ameer Ghani
84f21e99ef
cli: add --target-version CLI flags for migrate run/revert (#2538)
* cli: add --target-version CLI flags for migrate run/revert

* cli: fix broken test

* cli: test harness for `sqlx migrate` along with --target-version tests

* cli: Fail if version supplied to run/revert is too old/new

After some discussion with my coworkers, we thought about the behavior a bit more:

The behavior is now that for a run, if the provided version is too old, the CLI
will return with failure rather than being a no-op. This gives feedback to the
operator instead of being quiet.

It is still valid to up/downgrade to the latest version, this will still be a no-op
to allow for idempotency.
2023-07-31 12:49:53 -07:00
Jesse Wang
94379d88b3
fix(postgres): fix buffer management in PgCopyIn.read_from (#2630) 2023-07-24 16:07:29 -07:00
Max Vorobev
f2bb464bcd
Support naming migrations sequentially (#2602)
* Support naming migrations sequentially and inferring naming scheme

* Document new options and how naming is inferred

* Only account for up migrations when inferring ordering
2023-07-24 16:00:26 -07:00
Johannes
f7ce8fd9f4
Implement Default for QueryBuilder (#2605) 2023-07-14 16:28:14 -07:00
Austin Bonander
1d1095e94f
feat: allow opt-out of PgHasArrayType with #[derive(sqlx::Type)] (#2619)
closes #2611
2023-07-14 16:16:18 -07:00
Quang Le
74370f7ef0
Introduce build_query_scalar for QueryBuilder (#2551) 2023-07-14 10:42:19 -07:00
Luiz Carvalho
3db16751a0
feat(sqlx-core): add table function to database error (#2616) 2023-07-14 10:37:02 -07:00
Jonathan Newnham
afb6b1066e
improve docs about migration files (#2566) 2023-07-10 14:36:05 -07:00
Andrew Lilley Brinker
f06c4c27ce
Implement Clone for PoolOptions manually (#2548) (#2553)
* Implement Clone for PoolOptions manually (#2548)

Trying to derive `Clone` automatically for `PoolOptions` results
in errors when `clone` is actually called. This is because the
derive incorrectly determines that `Clone` is _not_ derivable
due to the lack of `Clone` implementation on the `DB: Database`
type parameter, even though no value of that type is actually
stored in a to-be-cloned position (in fact, it's only used for
the `Connection` associated type on the type parameter's
`Database` trait impl).

Manually implementing `Clone` side-steps this issue and insures
the type is always actually cloneable.

For reference: https://github.com/launchbadge/sqlx/issues/2548

* Ran 'cargo fmt'

* Simplified Arc cloning
2023-07-09 14:34:31 -07:00
Paolo Barbolini
a87a871913
Bump webpki-roots to v0.24 (#2597) 2023-07-08 12:42:32 -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
Andrew Lilley Brinker
1bdbedabdc
Impl AsMut for advisory lock types (#2520) (#2554)
The documentation for `PgAdvisoryLockGuard` lists a set of types
that should be able to be passed to it, but when actually trying
to do so, compilation would fail due to missing `AsMut` trait
implementations for those types. This commit adds the missing
`AsMut` impls so that `Transaction` and `PgConnection` can be used
as type parameters to `PgAdvisoryLockGuard`, as expected.

For reference: https://github.com/launchbadge/sqlx/issues/2520
2023-06-30 16:53:14 -07:00
Bastian
c2e54eae6f
add args to query builder (#2494) (#2506)
* add args to query builder (#2494)

* add test

* Update sqlx-core/src/query_builder.rs

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

* fmt

---------

Co-authored-by: Bastian Schubert <bastian.schubert@dock.financial>
Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
2023-06-30 14:26:25 -07:00
Paolo Barbolini
8c7f541324
Update rsa to 0.9 (#2563) 2023-06-30 14:10:02 -07:00
Paolo Barbolini
37fdc2043b
Update bitflags to v2 (#2564) 2023-06-30 12:34:33 -07:00
Paolo Barbolini
713da5b7b0
Bump indexmap and ahash (#2565) 2023-06-30 12:32:46 -07:00
Tim Geoghegan
0c8fe729ff
Traverse symlinks when resolving migrations (#2445)
* Traverse symlinks when resolving migrations

When enumerating the source directory seeking migration files, `sqlx`
ignores entries that aren't files. This was previously reported as #614
and fixed in #985 but apparently regressed somewhere along the way. This
commit reintroduces the fix from #985 to the current implementation: use
`std::fs::metadata` instead of `std::fs::DirEntry::metadata`. The former
is documented to traverse symlinks; the latter does not.

* add migrations_symlink test
2023-06-13 11:21:09 -07:00
Sergio Benitez
8f4063c511
Update rustls to 0.21, webpki-roots to 0.23 (#2440) 2023-05-11 15:19:24 -07:00
Austin Bonander
d43257e18a chore: cleanup, fix all non-deprecation warnings 2023-03-16 17:03:14 -07:00
Gregor Giesen
70934d7cd2 Docs of FromRow -> skip attribute updated as suggested by @abonander
Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
2023-03-13 18:06:44 -07:00
Gregor Giesen
6713e8cdaa Docs for skip attribute of FromRow macro 2023-03-13 18:06:44 -07:00
Blair Noctis
c03926c741 fix: lower default logging level for statements to Debug 2023-03-10 17:58:14 -08:00
Daniel Beckwith
cea7228fe0 Remove invalid impl 2023-03-10 14:36:46 -08:00
Daniel Beckwith
0b192cfda6 Add From impls for Json 2023-03-10 14:36:46 -08:00
Austin Bonander
c4b835c23a feat: add Connection::shrink_buffers, PoolConnection::close
closes #2372
2023-03-03 16:50:27 -08:00
Jayson Reis
82ff8d96b3 chore: Use tracing's fields to get structured logs
This also enables on services that can query this data to get useful metrics
2023-03-02 17:35:14 -08:00
Sergei Ivankov
21c2660062 Disable rustls crate logging feature by default 2023-03-01 19:17:35 -08:00
Austin Bonander
1fb1945aea fix(pool): close when last handle is dropped, extra check in try_acquire
closes #1928
closes #2375
2023-03-01 18:41:30 -08:00
Paolo Barbolini
c17c59fc4c Update dependencies 2023-02-22 15:49:46 -08:00
Austin Bonander
eade49cfb0
0.7.0-alpha.1 release 2023-02-21 14:56:54 -08:00
Thibs
c4130d45e3 Add client SSL authentication using key-file for Postgres, MySQL and MariaDB (#1850)
* use native-tls API

* Add client cert and key to MySQL connector

* Add client ssl tests for PostgreSQL

* Add client ssl tests for MariaDB and MySQL

* Adapt GA tests

* Fix RUSTFLAGS to run all tests

* Remove containers to free the DB port before running SSL auth tests

* Fix CI bad naming

* Use docker-compose down to remove also the network

* Fix main rebase

* Stop trying to stop service using docker-compose, simply use docker cmd

* Fix RUSTFLAGS for Postgres

* Name the Docker images for MariaDB and MySQL so we can stop them using their name

* Add the exception for mysql 5.7 not supporting compatible TLS version with RusTLS

* Rebase fixes

* Set correctly tls struct (fix merge)

* Handle Elliptic Curve variant for private key

* Fix tests suite

* Fix features in CI

* Add tests for Postgres 15 + rebase

* Python tests: fix exception for MySQL 5.7 + remove unneeded for loops

* CI: run SSL tests only when building with TLS support

---------

Co-authored-by: Barry Simons <linuxuser586@gmail.com>
2023-02-21 13:25:25 -08:00
Trangar
ad8ef8d608 Added regexp support in sqlite (#2189)
* CHANGELOG: mention that users should upgrade CLI

* Added regexp support in sqlite

* Added a with_regexp function to sqliteconnectoptions

* Fixed tests

* Undo CHANGELOG.md change

---------

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
Co-authored-by: Victor Koenders <victor.koenders@qrtech.se>
2023-02-21 13:25:25 -08:00
Paolo Barbolini
171b00de2e Start testing on Postgres 15 and drop Postgres 10 (#2193)
* CHANGELOG: mention that users should upgrade CLI

* Drop postgres 10 start testing postgres 15

---------

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
2023-02-21 13:25:25 -08:00
CosmicHorror
acaee75a30 Initial work to switch to tracing (#2185)
* Add tracing dep

* Switch over basic events

* Switch over dynamically enabled events

* Fix missing SocketAddr formatting

* More format fixing

* refactor: Apply tracing changes to new crate structure
2023-02-21 13:25:25 -08:00
Danilo Cianfrone
b72a52b066 fix: use owned Builder pattern for ConnectOptions (#2132)
* CHANGELOG: mention that users should upgrade CLI

* fix(sqlx-core): use owned builder pattern for ConnectOptions

---------

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
2023-02-21 13:25:25 -08:00
Luiz Carvalho
c09532864d feat: better database errors (#2109)
* feat(core): create error kind enum

* feat(core): add error kind for postgres

* feat(core): add error kind for sqlite

* feat(core): add error kind for mysql

* test(postgres): add error tests

* test(sqlite): add error tests

* test(mysql): add error tests

* fix(tests): fix tests rebasing

* refac(errors): add `ErrorKind::Other` variant
2023-02-21 13:25:25 -08:00
OverHash
771ab80a62 Use let else statements in favor of macro (#2213) 2023-02-21 13:25:25 -08:00
Max Bruckner
092922e42a Expose PoolOptions for reading (#2113)
This allows reading back PoolOptions that have already been set.
2023-02-21 13:25:25 -08: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
tyrelr
f0d6924f92 avoid improper path merger if cursor backing register, or cursor emptiness is different (#2120) 2023-02-21 13:25:25 -08:00
Rongcui Dong
3cb8e07b44 Sqlite EXPLAIN type inference improvements (#1984)
* AggValue and ROW_NUMBER()

* Some more functions

* cargo fmt
2023-02-21 13:25:25 -08:00
Thomas Alton
42dd78fe93 feat: Add set_connect_options method to Pool (#2088)
* feat: Add set_connect_options method to Pool

This allows external updates of the ConnectionOptions used when a new
connection needs to be opened for the pool.  The primary use case
is to support dynamically updated (read: rotated) credentials used
by systems like AWS RDS.

* Use Arc wrapper for ConnectOptions to reduce lock contention

* sqlite fix

* Use direct assignment instead of mem::swap

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

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
2023-02-21 13:25:25 -08:00