Commit graph

2120 commits

Author SHA1 Message Date
cycraig
20af5cd9c3
Use cargo check consistently in prepare (#2071) 2022-08-31 17:02:46 -07:00
cycraig
0823e1139c
Fix prepare race condition in workspaces (#2069)
* 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
2022-08-26 17:30:09 -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
Austin Bonander
956d8a823a
chore: add Discord link to issue templates 2022-08-15 18:07:50 -07:00
Austin Bonander
e04045cd66
fix: change extension of .github/ISSUE_TEMPLATE/config.yaml to .yml
YAML was a mistake, honestly.
2022-08-15 17:39:42 -07:00
Austin Bonander
ad594ce5cb
Add FAQ and discussions links 2022-08-15 17:36:53 -07:00
Austin Bonander
5245c9e627
Add issue templates (#2052) 2022-08-15 17:35:30 -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
Alexander Jackson
373b121a03
fix: use full macro path (#2028)
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.
2022-08-09 21:23:07 -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
728717f032
docs(FAQ): add answer about supported db versions 2022-08-03 13:59:27 -07:00
Austin Bonander
7809ff4b86 fix(docs): remove mention of subcommand that wasn't added
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.
2022-08-02 19:16:32 -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
うらむんオイル
5e08cd077e
docs: update versions (#1993) 2022-07-26 15:46:38 -07:00
Marco Neumann
58712ae552
docs: master -> main (#1990) 2022-07-21 19:06:16 -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
Austin Bonander
d7277f41eb
docs: clarify relationship between query_as! and FromRow (#1977) 2022-07-15 13:06:37 -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
60cc7c98fb
fix(actions): use rust-cache action (#1974)
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.
2022-07-14 00:44:01 -07:00
Ivan Kozik
b9a8f90b0c
fix(sqlx-cli): fix the build (#1969)
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())
    |                                                               ++
```
2022-07-14 00:09:53 -07:00
Joey McKenzie
d6c4eff81a
Add example with external query files (#1967)
* feat(examples): add files example for postgres

* fix(examples): add missing deps
2022-07-13 14:45:34 -07:00
Fredrik Park
7d8ded9a1a
Set CARGO_TARGET_DIR when compiling the prepare queries (#1910)
* 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
2022-07-12 17:25:52 -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
LovecraftianHorror
2c67e2a29e
Try avoiding a full clean in cargo sqlx prepare --merged (#1802)
* 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
2022-07-12 14:29:41 -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
LovecraftianHorror
d9fd21c94e
Don't cache sqlite connections for macros (#1930)
* fix(sqlx-macros): Don't cache sqlite connections for macros

* Explicity close SQLite connection in query macro
2022-07-09 14:35:24 -07:00
kenkoooo
842e1ba8eb
fix: typo in FAQ.md (#1955) 2022-07-08 20:10:36 -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
Austin Bonander
bd40cc9a2f
fix(ci): fix workflow to run on main, not master 2022-06-23 17:23:40 -07:00