Commit graph

354 commits

Author SHA1 Message Date
Austin Bonander
2ab7565bd8 chore: configure clippy cast lints at workspace level 2024-08-23 23:39:32 -07:00
Dirkjan Ochtman
a892ebc6e2
Upgrade to rustls 0.23 (#3399) 2024-08-04 16:39:13 -07:00
Cristian Le
92de9d42a6 Add LICENSE-* files to crates 2024-06-20 10:56:08 -07:00
Luiz Carvalho
1c7b3d0751
feat: new derive feature flag (#3113)
* feat: new derive feature flag

* doc: add new derive flag to readme

* fix: macros feature flag cfg
2024-03-30 15:24:56 -07:00
Luiz Carvalho
8f926e590c refac: rebase syn 2 changes 2024-03-14 12:03:40 -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
Luiz Carvalho
4095ac44ae
chore: add deprecation notice for type ascription use (#2483)
* chore: add deprecation notice for type ascription use

* docs: type ascription deprecation
2023-05-04 12:58:57 -07:00
Austin Bonander
eade49cfb0
0.7.0-alpha.1 release 2023-02-21 14:56:54 -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
Daniel Tashjian
d00a543613 PgHasArrayType for transparent types fix. (#2086)
Problem: PgHasArrayType was checking the application's postgres feature
Solution: only check the library's postgres feature

Co-authored-by: Daniel Tashjian <daniel@ecomedes.com>
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
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
RustyYato
c5f3513f7d
Fix expansion of sqlx(flatten) (#2023)
Given a generic type like `A<B>` before `sqlx` would produce
`A<B>::from_row(row)` which is invalid syntax.
Now it produces `<A<B> as ::sqlx::FromRow<'a, R>>`.
This also fixes a bug for non-generic types where an inherent method
might have been called instead of the `::sqlx::FromRow::from_row` method
because UFCS wasn't used.
2022-09-02 17:52:05 -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
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
Austin Bonander
cb52c7c62b chore: prep 0.6.1 release 2022-08-02 19:16:32 -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
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
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
Austin Bonander
17cebde64a
preparing 0.6.0 release (#1911)
* preparing 0.6.0 release

* run `cargo update` (not `upgrade`)
2022-06-16 15:53:09 -07:00
Kian-Meng Ang
d52f301a94
Fix typos (#1894)
* Fix typos

* Update CHANGELOG.md

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

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
2022-06-08 14:56:56 -07:00
Michael Freeborn
1b9c40b3c8
fix serde_json usage in macros (#1842) 2022-05-31 16:58:11 -07:00
LovecraftianHorror
a2691b9635
Reuse a cached DB connection instead of always recreating for sqlx-macros (#1782)
* refactor: Reuse a cached connection instead of always recreating for `sqlx-macros`

* fix: Fix type inference issue when no database features used

* refactor: Switch cached db conn to an `AnyConnection`

* fix: Fix invalid variant name only exposed with features

* fix: Tweak connection options for SQLite with `sqlx-macros`

* fix: Remove read only option for SQLite connection

* fix: Fix feature flags regarding usage of `sqlx_core::any`
2022-05-25 18:22:09 -07:00
LovecraftianHorror
826e63fc11
refactor(sqlx-macros): Ignore deps when getting metadata for workspace root (#1823) 2022-04-21 12:36:15 -07:00
Paolo Barbolini
fc9c9be5e8
Update to edition 2021 (#1808)
* Update to edition 2021

* Fix running tests
2022-04-15 12:52:00 -07:00
Paolo Barbolini
a97208c016
postgres: use Oid type everywhere instead of u32 (#1602)
* postgres: use Oid type instead of u32

* Make serde happy

* Expose the inner u32

* docs

* Try to fix tests

* Fix unit tests

* Fix order

* Not sure what happened here
2022-04-14 15:07:45 -07:00
Pruthvikar Reddy
cc1ab90110
Fix Rust type for SQLite REAL (#1785)
REAL is stored as as 8-byte IEEE floating point number
See https://www.sqlite.org/datatype3.html#storage_classes_and_datatypes
2022-04-14 15:05:38 -07:00
Austin Bonander
2e026cae67
prepare 0.5.12 release (#1800)
* prepare release 0.5.12

* chore: remove mentions of things happening in 0.6

except one mention that should still be happening in 0.6
2022-04-14 14:21:15 -07:00
Paolo Barbolini
ccbbe102b2
Update RustCrypto crates (#1625)
* Update RustCrypto crates

* rsa bump

* rsa dump

* rsa bump

* Bump rsa to 0.6.0-pre crates.io release

* Bump hkdf

* Resync Cargo.lock

* Bump rsa to 0.6.0
2022-04-11 11:24:09 -07:00
Tomáš Drtina
f4ed7e6ee8
Added support all variants of NUMERIC[] using decimal feature like bigdecimal does. (#1781) 2022-04-04 13:54:25 -07:00
Carol (Nichols || Goulding)
f5392151f3
Derive PgHasArrayType for transparent sqlx types (#1748)
Fixes #1744.
2022-03-23 16:41:36 -07:00
Paolo Barbolini
5b85a034da
Update heck to 0.4 (#1725) 2022-02-28 15:51:50 -08:00
Austin Bonander
eaf41fd092
prepare 0.5.11 release (#1715) 2022-02-18 13:49:06 -08:00
Bastian
dd39e79f8a
Support for lquery (#1710)
* initial lquery version

* share code between ltree/lquery

* more lquery functions

* fix rebase issues

* add version comment

* Update sqlx-core/src/postgres/types/lquery.rs

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

Co-authored-by: Bastian Schubert <bastian.schubert@crosscard.com>
Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
2022-02-17 15:06:35 -08:00
Bastian
6674e8ba96
Basic support for ltree (#1696)
* support ltree

* add default and push to PgLTree

* add more derived for ltree

* fix copy/paste

* Update sqlx-core/src/error.rs

Co-authored-by: Paolo Barbolini <paolo@paolo565.org>

* PR fixes

* ltree with name instead of OID

* custom ltree errors

* add pop ot PgLTree

* do not hide ltree behind feature flag

* bytes() instead of chars()

* apply extend_display suggestion

* add more functions to PgLTree

* fix IntoIter

* resolve PR annotation

* add tests

* remove code from arguments

* fix array

* fix setup isse

* fix(postgres): disable `ltree` tests on Postgres 9.6

Co-authored-by: Bastian Schubert <bastian.schubert@crosscard.com>
Co-authored-by: Paolo Barbolini <paolo@paolo565.org>
Co-authored-by: Austin Bonander <austin@launchbadge.com>
2022-02-15 20:40:03 -08:00
LovecraftianHorror
8f41f5b77a
refactor: Keep parsed sqlx-data.json in a cache instead of reparsing (#1684) 2022-02-15 20:17:47 -08:00
Austin Bonander
fdbfc5dfc3
Prepare 0.5.10 release (#1603)
* fix(cli): change new `rustls` and `native-tls` features to use correct runtime feature

* chore: upgrade SQLx crates to 0.5.10, upgrade all dependencies to latest versions

chore(cli): upgraded `clap` to `3.0.0-rc.9`

* fix(tests/sqlite): ignore `issue_1467()` as spuriously failing

I'm well aware of the principle that a spuriously failing test is a failing test, but even though I have it outputting the seed used with a reproducible PRNG, I can't reproduce the failures locally, so 🤷.

* chore: add CHANGELOG entry for 0.5.10
2021-12-29 17:25:49 -08:00
Austin Bonander
d25ab07f21
fix(test): fix mismatched type error in MySQL type tests (#1517)
* fix new warning about trailing semicolon in expression macros

* fix(test): fix mismatched type error in MySQL type tests
2021-10-26 13:45:46 -07:00
Austin Bonander
9abe9b3ac5
prepare 0.5.9 hotfix release (#1469) 2021-10-01 15:52:52 -07:00
Austin Bonander
1b5dd6514b
preparing 0.5.8 release (#1466)
* preparing 0.5.8 release

* fix warnings before release
2021-10-01 14:45:25 -07:00
Paolo Barbolini
efd08cc4b3
Reduce futures-util features (#1427)
* Reduce futures-util features

* Remove unused futures crate from sqlx-macros
2021-09-08 12:36:05 -07:00
Emil Gardström
2eb4ff8713
don't assert #[repr(...)] on #[derive(sqlx::Type)] unless needed (#1305) 2021-08-31 18:08:43 -07:00
Robert Collins
89ee690550
Don't require cargo to build offline queries (#1415)
In particular building with bazel and cargo-raze doesn't imply having
cargo at all, and deferring the lookup allows same-crate builds to
succeed with no change to semantics.

Fixes #1414

Signed-off-by: Robert Collins <robert.collins@cognite.com>
2021-08-31 17:35:50 -07:00
Austin Bonander
3749e0ea37
chore: prepare 0.5.7 (hotfix) release (#1394) 2021-08-20 17:14:42 -07:00
Austin Bonander
c04f83bcfe
fix(macros): use resolve_path when getting path for include_str!() (#1392)
fixes #1387
2021-08-20 15:46:32 -07:00