Commit graph

1124 commits

Author SHA1 Message Date
Austin Bonander
979a55da9d
feat: use specific message for slow query logs (#2880)
closes #2669
2023-11-15 20:08:09 -08:00
Austin Bonander
9dbd52c9b3
fix(core): avoid unnecessary wakeups in try_stream!() (#2850)
fixes #2834
2023-11-03 17:23:25 -07:00
Nano
ba87bf7473
Add impl FromRow for the unit type (#2827) 2023-10-23 16:45:33 -07:00
Dirkjan Ochtman
068ea14665
chore: bump some sqlx-core dependencies (#2826)
* chore: update Cargo.lock

* chore: avoid deprecated chrono API

* chore: avoid deprecated rustls API

* chore: bump webpki-roots to 0.25

* chore: remove unused generic-array dependency
2023-10-23 15:19:55 -07:00
Anup Jadhav
49ccc7ca32
issue #2821 Update error handling logic when opening a TCP connection (#2822)
This commit updates the error handling logic in the `connect_tcp` function. Previously, the function would panic if the hostname did not resolve to at least one address.

The updated logic attempts to establish a TCP connection for each address that the hostname resolves to. If it fails to connect to any of the addresses, it will return the last encountered error. If the hostname doesn't resolve to any addresses, the function returns a custom error message stating "Hostname did not resolve to any addresses".
2023-10-19 14:55:45 -07:00
Gregor Giesen
54c5d6bc3c
derive FromRow: sqlx(default) for all fields (#2801)
* derive FromRow: sqlx(default) for all fields

* error in test_struct_default fixed

* derive FromRow: struct level sqlx(default) requires and uses Default implementation

* Update sqlx-core/src/from_row.rs

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

* Update sqlx-core/src/from_row.rs

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

* satify cargo fmt

---------

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
2023-10-17 16:13:40 -07:00
失魂魚
a7d2703d64
Add additional info regarding using Transaction and PoolConnection as Executor (#2713)
Copy-paste from https://github.com/launchbadge/sqlx/blob/main/CHANGELOG.md#070---2023-06-30
2023-10-17 16:11:56 -07:00
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
cycraig
e5f91ab52f Fix sqlite compilation (#2098) 2023-02-21 13:25:25 -08:00
Lining Pan
75a34951ab Fix compile time verification performance regression for sqlite (#1946)
* add instruction, register, and cursor state memorization

* fix: fixed formating
2023-02-21 13:25:25 -08:00
tyrelr
d5b8c66e24 Fix sqlite update return and order by type inference (#1960)
* add failing test cases for update/delete return into

* fix regression in null tracking by improving tracking of cursor empty/full state

* add failing test case for order by column types

* Add support for SorterOpen,SorterInsert,SorterData

* add failing test case for unions

* fix range copy/move implementation

* fix wrong copy/move range

* remove calls to dbg!
2023-02-21 13:25:25 -08:00
Pekka Enberg
d23be3bfa8 Update libsqlite3-sys to 0.25.1 (#2094) 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
tyrelr
8fca76065a
Sqlite explain plan log efficiency (#2091)
* capture operation codes by reference

* use Vec instead of HashSet for results

* check logging enabled before cloning result
2022-09-12 18:22:15 -07:00
Adam Cigánek
f38c739f7f
fix: make begin,commit,rollback cancel-safe in sqlite (#2054) (#2057) 2022-09-12 18:20:27 -07:00
Marco Neumann
5e56da87e0
fix: ensure migration progress is not lost for PG, mysql and sqlite (#1991)
* fix: ensure migration progress is not lost for PG

Fixes #1966.

* fix: ensure migration progress is not lost for sqlite

This is similar to #1966.

* fix: ensure reverse migration progress is not lost for PG

See #1966.

* fix: ensure reverse migration progress is not lost for sqlite

See #1966.

* fix: ensure migration progress is not lost for mysql

This is similar to #1966.

* fix: ensure reverse migration progress is not lost for mysql

See #1966.

* test: check migration type as well

* test: extend migrations testing

* fix: work around MySQL implicit commits

* refactor: simplify migration testing
2022-09-12 17:52:04 -07:00
zz
ddffaa7dde
feat: Add try_from attribute for FromRow (#1081) 2022-09-06 21:04:11 -07:00
fuzzbuck
18a76fbdbf
customizable db locking during migration (#2063)
* customizable db locking during migration

* Update sqlx-core/src/migrate/migrator.rs

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

* [migrator.rs] cargo fmt

* fix Migrator 'locking' param doctest fail

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
2022-09-06 13:42:56 -07:00
Rinat Shigapov
04884f1a1a
close unnamed portal after each executed extended query (#2081)
This allows to free server resources earlier and run the same logic as simple Query does:

"The simple Query message is approximately equivalent to the series Parse, Bind, portal Describe, Execute, Close, Sync,"
2022-09-02 17:49:31 -07:00
Richard Bradfield
20877d83fd
Add extension support for SQLite (#2062)
* Add extension support for SQLite

While SQLite supports loading extensions at run-time via either the C
API or the SQL interface, they strongly recommend [1] only enabling the C
API so that SQL injections don't allow attackers to run arbitrary
extension code.

Here we take the most conservative approach, we enable only the C
function, and then only when the user requests extensions be loaded in
their `SqliteConnectOptions`, and disable it again once we're done
loading those requested modules. We don't add any support for loading
extensions via environment variables or connection strings.

Extensions in the options are stored as an IndexMap as the load order
can have side effects, they will be loaded in the order they are
supplied by the caller.

Extensions with custom entry points are supported, but a default API
is exposed as most users will interact with extensions using the
defaults.

[1]: https://sqlite.org/c3ref/enable_load_extension.html

* Add extension testing for SQlite

Extends x.py to download an appropriate shared object file for supported
operating systems, and uses wget to fetch one into the GitHub Actions
context for use by CI.

Overriding LD_LIBRARY_PATH for only this specific DB minimises the
impact on the rest of the suite.
2022-09-01 15:03:27 -07:00
Tobias Tschinkowitz
9de70d2e7a
fix: mssql uses unsigned for tinyint instead of signed (#2074) 2022-08-31 18:10:29 -07:00
amos
4c9d23960a
SqliteConnectOptions typo (#2072) 2022-08-26 15:45:32 -07:00
Rakshith Ravi
3f7111f05d
Updated documentation to reflect inet allows for IpAddr (#2053)
Co-authored-by: Austin Bonander <austin.bonander@gmail.com>

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
2022-08-23 15:45:29 -07:00
Adam Cigánek
2d65c5de80
fix: use unlock notify also on sqlite3_exec (#2021) (#2055) 2022-08-22 20:01:48 -07:00
Austin Bonander
5790ffc8d3
fix(docs): close code block in query_builder.rs (#2067)
@danielakhterov and I were playing around with counting lines using regex and noticed that SQLx had an odd number of ` ``` ` and got a little nerd-sniped trying to find it.
2022-08-22 19:54:18 -07:00
Ophir LOJKINE
0e5b9a1bea
fix typo in documentation (#2058) 2022-08-17 17:17:12 -07:00
stoically
26f60d9525
chore: Switch to sha1 crate (#2056) 2022-08-16 17:51:29 -07:00
zach
326254fb51
Fix typo in FromRow docs (#2040)
Fixes typo: manuel to manual.
2022-08-11 14:24:57 -07:00
Marcus Lee
ca74b0c141
added flag for PIPES_AS_CONCAT connection setting for MySQL to fix #2034 (#2046) 2022-08-11 14:24:32 -07:00
NSMustache
c4f1816f76
Bump sqlformat to 0.2.0 (#2025)
Fixes #2024
2022-08-08 14:34:56 -07:00
szymek156
c931cab95f
Szymek156/issue2009 (#2014)
* SQLite: Execute SQLCipher pragmas as very first operations on the database

SQLCipher requires, apart from 'key' pragma also other cipher-related
to be executed before read/write to the database.

* Added tests for SQLCipher functionality

* remove default-features from libsqlite3-sys when building from dev-dependencies

Co-authored-by: Szymon Zimnowoda <szimnowoda.memri@gmail.com>
2022-08-05 12:20:14 -07:00
Austin Bonander
cb52c7c62b chore: prep 0.6.1 release 2022-08-02 19:16:32 -07:00
Lining Pan
b630d5c748
feat: allow vfs to be set as uri query parameter (#2013)
* feat: allow vfs to be set as uri query parameter

* fix: handle VFS name as a string

* fix: avoid unnecessary copies of vfs name
2022-08-02 15:59:43 -07:00
Austin Bonander
054f61980a
feat: implement testing utilities (#2001) 2022-08-02 14:38:12 -07:00
Rob Ede
7adbb7fefc
refactor: remove direct actix-rt support (#1679)
actix- runtime feature flags are now aliases for tokio- flags
2022-08-01 21:48:40 -07:00
Austin Bonander
9a6d07f10a
feat: QueryBuilder improvements (#2005)
* get raw SQL
* method to build `QueryAs` instead of `Query`
2022-07-28 20:02:05 -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
Marco Neumann
29073cbe84
fix: ensure PG connection is established before using it (#1989)
Fixes #1940.
2022-07-27 13:58:36 -07:00
Erik
78a0a5943a
Add example for manual implemenation of the FromRow trait (#1495)
* chore: add doc example for manual implemenation of FromRow trait

* fix typo

Co-authored-by: Jonas Platte <jplatte@users.noreply.github.com>

* chore: use `sqlx::Result` directly

Co-authored-by: Jonas Platte <jplatte@users.noreply.github.com>
2022-07-19 14:31:10 -07:00
Vladimir
8fc4625ec7
Add push_bind_unseparated for Separated in query builder (#1985) 2022-07-19 00:10:33 -07:00
Stephen Becker IV
dbb1feebda
Add in an example of how to use separated (#1902)
* Add in an example of how to use separated

Dearest Maintainer,

Thank you for your work on this project. I started using query builder today and I have enjoyed it. I did have a hard time figuring out how best to use separated to generate the values for an IN statement. It is my hope that adding an example will save someone else a few minutes of code reading or compile time. I wrote the example in the github text editor but It looks correct.    

Thanks again for your work on this.
Becker

* end ```

* Apply cfg and end ```

* remove dup

* Update sqlx-core/src/query_builder.rs
2022-07-15 12:33:53 -07:00
Vladimir
28e22e1259
add push_tuples for QueryBuilder (#1954)
* add `push_tuples` for QueryBuilder

* update docs

* fix docs
2022-07-15 12:11:21 -07:00
Yota Toyama
9534de3476
Fix type info access in Any database driver (#1848)
* Fix type info access in `Any` database driver

* Implement custom receiver methods

* Revert "Fix type info access in `Any` database driver"

This reverts commit a2845c74c5e545351f3f0f2fa6851e7f23a60621.

* Refactor

* Update sqlx-core/src/any/row.rs

Co-authored-by: Yota Toyama <raviqqe@gmail.com>

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
2022-07-14 14:17:57 -07:00
Austin Bonander
6de3e09816
fix(postgres): don't panic if S or V Notice fields are not UTF-8 (#1968)
* fix(postgres): don't panic if `S` or `V` Notice fields are not UTF-8

* fix: run `cargo update` to rotate cache key

for some reason there's some bad compiler artifacts cached
2022-07-12 17:23:13 -07:00
Théo OIRY
7cdb68be1a
support flatten attribute in FromRow macro (#1959)
* support flatten attribute in FromRow macro

* added docs for flatten FromRow attribute
2022-07-12 14:28:07 -07:00
Austin Bonander
bc3e70545b
sqlite improvements (#1965)
* use direct blocking calls for SQLite in `sqlx_macros`
    * this also ensures the database is closed properly, cleaning up tempfiles
* don't send `PRAGMA journal_mode` unless set
    * this previously defaulted to WAL mode which is a permanent setting
      on databases which doesn't necessarily apply to all use-cases
    * changing into or out of WAL mode acquires an exclusive lock on the database
      that can't be waited on by `sqlite3_busy_timeout()`
    * for consistency, `sqlx-cli` commands that create databases will still
      create SQLite databases in WAL mode; added a flag to disable this.
* in general, don't send `PRAGMA`s unless different than default
    * we were sending a bunch of `PRAGMA`s with their default values just to enforce
      an execution order on them, but we can also do this by inserting empty slots
      for their keys into the `IndexMap`
* add error code to `SqliteError` printout
* document why `u64` is not supported
2022-07-12 13:59:37 -07:00
Valentin
9ca1fbf2ca
Support Rust arrays in Postgres (#1953) 2022-07-08 16:56:47 -07:00
John B Codes
cfef70a796
Add Sqlite support for the time crate (#1865)
* feat(sqlite): Add 'time' crate support for date/time types
docs(sqlite): Update types module docs for JSON and Chrono
docs(mysql): Update types module docs for JSON

* More efficient time crate decoding with FormatItem::First and hand-crafting of format descriptions

* Replace temporary testing code with original intention

* Replace duplicated formatting test with intended test

* Performance improvements to decoding OffsetDateTime, PrimitiveDateTime, and Time

* Use correct iteration for OffsetDateTime

* Reduce visibility of format constants

Co-authored-by: John B Codes <johnbcodes@users.noreply.github.com>
2022-07-08 16:51:50 -07:00
Valentin
b3bbdab705
Fix panic in Postgres Bytes decode (#1948)
This function can panic due to slicing out of bounds when the server
responds without the `\x` prefix. With this commit we instead error and
also ensure that the prefix is what we expect instead of blindly
removing it.

Not directly related to the panic, we replace as_str() with as_bytes()
because there is no reason to perform a utf8 validity check when
hex::decode already checks that the content is valid.
2022-07-06 18:23:29 -07:00
James H
79ebd3005a
docs: added docs for json (#1917)
* fix: added docs for json

* fix: doc tests
2022-06-30 17:53:46 -07:00