* Separate offline query metadata per crate
* Update sqlx-cli prepare to use separate query metadata per crate
* Add resolve.root to metadata test fixture
* Simplify root package resolution
* Fix prepare --merged
@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.
When the `#[sqlx::test]` macro is imported using `#[macro_use]` such as
in the following example:
```rust
extern crate sqlx;
mod tests {
#[test]
fn something() {}
}
```
then the `#[test]` generated by the macro will refer to itself instead
of the standard Rust `#[test]` macro. This will cause `rustc` to
recursively expand it and produce the following error message:
```
thread 'rustc' has overflowed its stack
fatal runtime error: stack overflow
```
Instead, we can just refer to the standard macro by using its fully
qualified path.
This PR:
* Swaps `#[test]` usages in `#[sqlx::test]` for their hygenic path to
prevent recursive expansion alongside `#[macro_use]`
Closes#2017.
* 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>
I intended to add subcommands to `sqlx-cli` to manage test databases but I wanted to get #2001 finished and out the door so we can start using it ASAP.
* 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>
* 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
I think the CI failures we've been seeing lately are due to bad incremental compilation artifacts being cached. The rust-cache action is smarter about what it actually caches.
This fixes:
```
error[E0616]: field `target_directory` of struct `metadata::Metadata` is private
--> sqlx-cli/src/prepare.rs:175:47
|
175 | .env("CARGO_TARGET_DIR", metadata.target_directory.clone())
| ^^^^^^^^^^^^^^^^ private field
|
help: a method `target_directory` also exists, call it with parentheses
|
175 | .env("CARGO_TARGET_DIR", metadata.target_directory().clone())
| ++
```
* Move compiled query data
I did try to set rustc's --out-dir but encountered a strange error
stating that it can not be set more than once (even though I am unable
to deduce what else is setting it).
This enabled me to set a custom CARGO_TARGET_DIR and still be able to
prepare queries.
* Set CARGO_TARGET_DIR in the rustc invocation
* 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
* refactor(sqlx-cli): Try avoiding a full clean with `--merged`
* docs(sqlx-cli): Sprinkle some comments on the metadata changes
* refactor(sqlx-cli): Make the new recompiltion setup unit-testable
* fix(sqlx-cli): Only pass in `$RUSTFLAGS` when set when using `--merged`
* refactor(sqlx-cli): `cargo clean -p` works by name so rip out pkgid code
* chore(sqlx-cli): Remove unused imports
* 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
* 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>
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.