* Make encode and encode_by_ref fallible
This only changes the trait for now and makes it compile, calling .expect() on all users. Those will be removed in a later commit.
* PgNumeric: Turn TryFrom Decimal to an infallible From
* Turn panics in Encode implementations into errors
* Add Encode error analogous to the Decode error
* Propagate decode errors through Arguments::add
This pushes the panics one level further to mostly bind calls. Those will also be removed later.
* Only check argument encoding at the end
* Use Result in Query internally
* Implement query_with functions in terms of _with_result
* Surface encode errors when executing a query.
* Remove remaining panics in AnyConnectionBackend implementations
* PostgreSQL BigDecimal: Return encode error immediately
* Arguments: Add len method to report how many arguments were added
* Query::bind: Report which argument failed to encode
* IsNull: Add is_null method
* MySqlArguments: Replace manual bitmap code with NullBitMap helper type
* Roll back buffer in MySqlArguments if encoding fails
* Roll back buffer in SqliteArguments if encoding fails
* Roll back PgArgumentBuffer if encoding fails
* Include test case for regular subtransactions
While using COPY and subtransactions I kept running into errors.
This test case documents that error, it currently fails with:
Error: encountered unexpected or invalid data: expecting ParseComplete but received CommandComplete
* PostgreSQL Copy: Consume ReadyForQuery on error
When a COPY statement was in error inside a subtransaction,
a Protocol Error used to be raised. By consuming the ReadyForQuery
message when there is an error, we no longer have this issue.
* fix(postgres) : int type conversion while decoding
* Check value buffer len when decoding integer type in postgres
* decode from octal for postgres i8
---------
Co-authored-by: RaghavRox <66472843+RaghavRox@users.noreply.github.com>
* test: add a failing test
* feat: add no_tx to migration struct
* feat: execute migration with no tx block
* fix: expected string literal compilation error
* test: update no tx to content comment
* refactor: use the sql comment instead of file name semantics
* docs: remove no_tx from file format comment
* fix: remove filename matches
* fix: messed up merge
* refactor: dedupe migration
* fix: move comment to where it makes sense
* fix: linter error
* HasValueRef, HasArguments, HasStatement -> Database GATs
replace the associated types from the generic traits
`HasValueRef<'r>`, `HasArguments<'q>` and `HasStatement<'q>`
with generic associated types in `Database`
* fixup after rebase
---------
Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
* feat: add get_url to connect options
Add a get_url to connect options and implement it for all needed types;
include get_filename for sqlite. These changes make it easier to test
sqlx.
* refactor: use expect with message
* refactor: change method name to `to_url_lossy`
* fix: remove unused imports
Exposes some of the main fields for PgConnectOptions
and MySqlConnectOptions. Exposed fields include: host,
port, socket, ssl mode, application name, and charset.
* Updated ahash so it can compile on mac
* Updated MigrateDatabase Trait + related functions
* Postgres force drop database flag impl
* Update migrate.rs
* Reverted MigrateDatabase Trait
* Update migrate.rs
* Update migrate.rs
* Added force drop database fn impl
* Add Migrate Error
* Fixed changed function name
This is often encountered when the host the db is on is restarted.
For example, a reboot of AWS Aurora causes this. If we don't handle this
properly the PgListeners are stuck in an erroring state, even when the DB
is back online. By catching it here, we will reconnect when it is
(eventually) back online.
* feat(citext): implement citext for postgres
* feat(citext): add citext -> String conversion test
* feat(citext): fix ltree -> citree
* feat(citext): add citext to the setup.sql
* chore: address nits to #2478
* Rename `PgCitext` to `PgCiText`
* Document when use of `PgCiText` is warranted
* Document potentially surprising `PartialEq` behavior
* Test that the macros consider `CITEXT` to be compatible with `String` and friends
* doc: add `PgCiText` to `postgres::types` listing
* chore: restore missing trailing line break to `tests/postgres/setup.sql`
---------
Co-authored-by: Austin Bonander <austin@launchbadge.com>
* fix(postgres): sqlx prepare fails if shared_preload_libraries=pg_stat_statements
closes#2622
refs:
* https://serde.rs/enum-representations.html#untagged
* https://serde.rs/field-attrs.html#skip
* https://www.postgresql.org/docs/current/pgstatstatements.html
* https://www.postgresql.org/docs/current/runtime-config-statistics.html#GUC-COMPUTE-QUERY-ID
* fix(postgres): regression of #1449
```
error: error occurred while decoding column 0: data did not match any variant of untagged enum Explain at line 3 column 1
Error: --> tests/postgres/macros.rs:103:15
|
103 | let row = sqlx::query!(r#"CALL forty_two(null)"#)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the macro `$crate::sqlx_macros::expand_query` which comes from the expansion of the macro `sqlx::query` (in Nightly builds, run with -Z macro-backtrace for more info)
error: could not compile `sqlx` (test "postgres-macros") due to previous error
```
* refactor(postgres): don't define unused fields in QueryPlan
* refactor(postgres): simplify query plan handling, add unit test
* chore: document why we load `pg_stat_statements` in tests
---------
Co-authored-by: mrl5 <31549762+mrl5@users.noreply.github.com>
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
```