Commit graph

1118 commits

Author SHA1 Message Date
liushuyu
dfd9cf59f1
fix(postgres): fix option passing logic (#1731)
Co-authored-by: Austin Bonander <austin@launchbadge.com>

Co-authored-by: Austin Bonander <austin@launchbadge.com>
2022-03-01 21:29:38 -08:00
Andre B. Reis
99d3220d88
Impl PgHasArrayType for serde_json::{Value,RawValue} (#1722)
* Implement PgHasArrayType for JSON types in the serde_json crate

* Remove redundant Type impls for arrays and Vecs of JsonValue

* Relax an implicit Sized bound to support JsonRawValue
2022-02-23 12:57:48 -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
05storm26
8bccd53346
Allow converting AnyConnectOptions to a specific ConnectOptions (#1610) 2022-02-17 14:57:48 -08:00
stoically
45854a4246
docs: Acquire examples and alternative (#1687) 2022-02-17 14:55:38 -08:00
Andrew Wheeler(Genusis)
183e620381
Implement From for AnyConnection (#1652)
* Implemented From for AnyConnection to cover the 4 Database type connections to AnyConnection

* formatting
2022-02-16 18:59:32 -08:00
Arttu Liimola
160f345f4f
Fix Option for Any driver. (#1661)
With macro impl_encode_for_option Null values are not added, when creating arguments for the actual driver selected at runtime.
2022-02-15 21:12:02 -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
Marco Napetti
2849468e57
Avoid panicking if packet empty (#1667)
I'm having panics on those index accesses, an empty packet is probably a symptom of other problems, but it would be cool if the application doesn't panics like it does.
2022-02-15 20:11:38 -08:00
Adam Cigánek
347374b94b
SQLite unlock notification (#1658)
* sqlite: add test for concurrent table access (failing)

* sqlite: implement unlock notification
2022-02-15 20:10:36 -08:00
VersBinarii
fd2d26e12d
Fix power calculation when encoding the BigDecimal into NUMERIC (#1692)
* Show failing test

0.002 will be encoded as 0.02

* The power calculation should depend on the offset

of the digits
2022-02-11 12:28:07 -08:00
Daniel Beckwith
d901694ec6
Add target context to Postgres notice logs (#1606)
Adds a `target` field to the Postgres notice logs and filters based on that target, just like how the query logs do it.
2022-01-04 15:37:37 -08:00
Andrew Whitehead
dec0ed1a4d
drop worker shared state in shutdown (#1608)
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
2022-01-04 15:37:16 -08:00
Paolo Barbolini
bcb2d8e604
Remove unused dependencies (#1605) 2022-01-03 16:56:01 -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
63ca2ccc6c
refactor(sqlite): make background thread responsible for all FFI calls (#1551) 2021-12-29 15:23:02 -08:00
liushuyu
b3091b0322
feat(postgres): add an option to specify extra options (#1539)
* feat(postgres): add an option to specify extra options ...

... this allow you to specify stuff like search path and statement
timeouts etc.

* feat(postgres): set options through setting run-time parameters

* feat(postgres): use flat command-list instead of hashmap

* feat(postgres): make the options taking parameters with `Display` trait
2021-12-29 13:10:18 -08:00
Charles Samborski
32f1273565
Fix support for Postgres array of custom types (#1483)
This commit fixes the array decoder to support custom types. The core of the issue was that the array decoder did not use the type info retrieved from the database. It means that it only supported native types.

This commit fixes the issue by using the element type info fetched from the database. A new internal helper method is added to the `PgType` struct: it returns the type info for the inner array element, if available.

Closes #1477
2021-12-29 13:05:15 -08:00
Pieter
dee514704f
Postgres: Array enum encoding (#1511)
* Postgres: Add test for array enum

* Allow produces() to override type_info() as per doc

* run cargo fmt
2021-12-29 13:04:42 -08:00
Douman
04109d9323
Reimport Either used in Executor (#1562)
* Reimport Either used in Executor

* Re-import sqlx-core

* Update src/lib.rs

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

* Apply fmt

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
2021-12-29 13:01:16 -08:00
Rob Gilson
f79d321b78
fix(postgres): Match ~/.pgpass password after URL parsing and fix user and database ordering (#1566)
* fix(postgres): Fixes pgpass so it applies after parsing and matches usernames & databases correctly

* chore: Updated unit test

* refactor: Previous semantics of PgConnectOptions::default()

* refactor: formatting
2021-12-29 13:00:49 -08:00
Paolo Barbolini
fca866d0bc
Update itoa and dirs (#1601) 2021-12-29 11:56:58 -08:00
05storm26
beb2100f29
Make the database kind queryable from AnyConnectionKind and AnyConnection (#1592) 2021-12-28 17:19:26 -08:00
parazyd
d258e8c681
core/sqlite: Add special case for sqlcipher key pragma when connecting. (#1587)
* core/sqlite: Add special case for sqlcipher key pragma when connecting.

* core/sqlite: Move std::fmt::Write import to module level.
2021-12-27 15:33:06 -08:00
Paolo Barbolini
ce572bcee4
Update rsa crate to 0.5 (#1572)
* Update rsa crate to 0.5

* Don't do pem decoding ourselves
2021-12-20 17:58:37 -08:00
Josh Triplett
2e6ab7c3de
Make whoami optional, and only pull it in for postgres (#1571)
sqlx-core uses whoami to provide the fallback for postgres username. If
not building postgres support, omit the dependency on whoami.
2021-12-20 17:54:58 -08:00
Jonas Platte
12d9f54c7d
Rewrite Postgres array type handling (#1385)
… to reduce boilerplate and allow custom types.
2021-11-22 17:17:00 -08:00
nitnelave
5aef7d7801
Add a get_kind method to Pool (#1228) 2021-11-22 17:00:00 -08:00
David Yamnitsky
8299687878
bump libsqlite3-sys to 0.23.1 (#1535) 2021-11-12 14:37:19 -08:00
Akira Hayakawa
a304161b28
Copy API improvement (#1536) (#1537)
* expose PgCopyIn

* downgrade Pool<Posgres> copy_in_raw/out_row to take &self
2021-11-12 14:15:15 -08:00
Kirill Mironov
df2d5c7a1b
Encode/Decode impl for Cow<'_, str> (#1343)
* Encode/Decode impl for Cow<'_, str>

resolves #1214

* --wip-- [skip ci]

* Add Cow decode/encode to other databases and fix build
2021-11-08 18:58:24 -08:00
yuyawk
626dd0db38
fix panic when converting negative chrono::Duration into PgInterval (#1475)
* fix PgInterval convert failure for negative chrono::Duration

* add unit tests for PgInterval

* Fix: remove redundancy because nanosecond overflow implies microsecond overflow
2021-11-08 18:47:57 -08:00
yuyawk
cdb40b1f8e
derive Clone, Copy for AnyKind (#1474) 2021-11-08 18:45:19 -08:00
Austin Bonander
b419bf5298
docs: revise Pool docs in a couple places (#1526) 2021-11-04 18:52:55 -07:00
meh
62b57f021f
fix(postgres): allow rust_decimal::Decimal in PgRange (#1523)
* fix(postgres): allow rust_decimal::Decimal in PgRange

* test(postgres): add tests for BigDecimal and Decimal in ranges
2021-11-03 12:28:39 -07:00
Daniel Imfeld
1efbbcaffa
Reduce indexmap version to 1.6.2 (#1501)
deno_core currently uses `=1.6.2` for indexmap, and Cargo refuses to resolve a version with sqlx's requirement of 1.7.0.

004d07dccd/core/Cargo.toml (L18)
2021-11-02 18:22:49 -07:00
Akira Hayakawa
f1851e7832
Add persistent setter (#1503) (#1508) 2021-11-02 18:08:15 -07:00
Lucille Blumire
4ada6ac7e1
Add support for serialized threading mode to sqlite (#1514)
* Add support for serialized threading mode

* Typos

* Fix build
2021-11-02 18:07:56 -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
Billy Chan
8561891474
[SQLite] encoding & decoding NaiveTime with correct format (#1459)
* Fix SQLite encoding format

* Update SQLite decoding format

* Update sqlx-core/src/sqlite/types/chrono.rs

* fixup: add `#[rustfmt::skip]`

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
Co-authored-by: Austin Bonander <austin@launchbadge.com>
2021-09-30 19:45:48 -07:00
Austin Bonander
51e45ce3ab
Revert "feat: allow log level customization (#1371)" (#1465)
This reverts commit 719d80038b.
2021-09-30 18:58:42 -07:00
Andrew Whitehead
ba3e373b7e
Shut down statement worker in Sqlite Connection::close (#1453)
* add explicit shutdown of sqlite statement worker in Connection::close()

Signed-off-by: Andrew Whitehead <cywolf@gmail.com>

* test sqlite database close method

Signed-off-by: Andrew Whitehead <cywolf@gmail.com>

* await worker shutdown after dropping SqliteConnection

Signed-off-by: Andrew Whitehead <cywolf@gmail.com>

* restore explicit drop

Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
2021-09-30 18:14:30 -07:00
Paolo Barbolini
c2e04a1f3c
Upgrade hmac to 0.11 (#1443) 2021-09-23 12:05:31 -07:00
Austin Bonander
8b30f3059b
Fix a panic in the worker thread when dropping the connection while SqliteRows still exist (#1450)
* chore(sqlite): add repro for #1419

* fix(sqlite): hold a reference to the connection in `SqliteRow`

fixes #1419
2021-09-22 16:55:22 -07:00
Kohei Suzuki
593364f801
fix(mysql): handle multiple waiting results correctly (#1439)
* test(mysql): add test case for pending rows and dropped transaction

* fix(mysql): handle multiple waiting results correctly
2021-09-22 13:39:56 -07:00
Ghass Mo
a5997a2813
Support custom initial options for sqlite (#1295)
* Support custom initial options for sqlite

Apply suggestions from code review

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

Apply suggestions from code review

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

Use order-preserving map to set pragmas for an initial sqlite statement

 Use Cow<'static, str> instead of String

Co-authored-by: Austin Bonander <austin@launchbadge.com>
2021-09-13 13:48:24 -07:00
Austin Bonander
2307f432eb
fix: run cargo fmt 2021-09-13 13:14:24 -07:00
Montana Low
ec510b37e7
Finish support for Postgres COPY (#1345)
* feat(postgres): WIP implement `COPY FROM/TO STDIN`

Signed-off-by: Austin Bonander <austin@launchbadge.com>

* feat(postgres): WIP implement `COPY FROM/TO STDIN`

Signed-off-by: Austin Bonander <austin@launchbadge.com>

* test and complete support for postgres copy

Co-authored-by: Austin Bonander <austin@launchbadge.com>
2021-09-13 13:03:38 -07:00
David Marcin
687fbf9909
Support the immutable option on SQLite connections (#1289)
Co-authored-by: Austin Bonander <austin@launchbadge.com>
2021-09-10 15:47:30 -07:00
Paolo Barbolini
092f811f62
Fix CIDR[] not being compatible with Vec<IpNetwork> (#1433) 2021-09-10 15:43:04 -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
Elise
719d80038b
feat: allow log level customization (#1371) 2021-08-31 17:51:48 -07:00
Jonas Platte
335eed4545
Add executor trait "aliases" (#1412) 2021-08-31 17:36:27 -07:00
Jonas Platte
d94c081468
Add more debugging info to unresolved type declaration panic (#1416) 2021-08-31 17:35:10 -07:00
Simon Paitrault
135d16a34f
Getting current Handle in Drop (#1395)
Signed-off-by: Freyskeyd <simon.paitrault@gmail.com>
2021-08-30 14:11:49 -07:00
Austin Bonander
3749e0ea37
chore: prepare 0.5.7 (hotfix) release (#1394) 2021-08-20 17:14:42 -07:00
Austin Bonander
0e8ffb564b
fix(postgres): avoid recursively spawning tasks in PgListener::drop() (#1393)
refactor(pool): deprecate `PoolConnection::release()`, provide renamed alts
2021-08-20 16:44:46 -07:00
Austin Bonander
207e6db2ce
chore: bump versions of sqlx-* in dependencies 2021-08-17 12:49:02 -07:00
Austin Bonander
6bb1c716bd
preparing 0.5.6 release (#1382)
* fix(pool): reenable connection reaper

* fix warnings

* chore: bump published crates to 0.5.6

* chore: update CHANGELOG.md for 0.5.6
2021-08-17 12:44:24 -07:00
Altan Özlü
774880d17c
cockroachdb fix for macro (#1386) 2021-08-17 12:20:08 -07:00
Atkins
dd27aa0587
Fix bug for PostgreSQL if the statement has type holes (#1363)
* fix: wait until ready after executing other helper queries while pg quering is executing

Signed-off-by: Atkins Chang <atkinschang@gmail.com>

* fix: use tls parameter for testing target

Signed-off-by: Atkins Chang <atkinschang@gmail.com>
2021-08-16 16:50:11 -07:00
Austin Bonander
71388a7ef2
sqlite: fix a couple segfaults (#1351)
* sqlite: use Arc instead of Copy-able StatementHandle

This guarantees that StatementHandle is never used after calling
`sqlite3_finalize`. Now `sqlite3_finalize` is only called when
StatementHandle is dropped.

(cherry picked from commit 5eebc05dc3)

* sqlite: use Weak poiter to StatementHandle in the worker

Otherwise some tests fail to close connection.

(cherry picked from commit 5461eeeee3)

* Fix segfault due to race condition in sqlite (#1300)

(cherry picked from commit bb62cf767e)

* fix(sqlite): run `sqlite3_reset()` in `StatementWorker`

this avoids possible race conditions without using a mutex

* fix(sqlite): have `StatementWorker` keep a strong ref to `ConnectionHandle`

this should prevent the database handle from being finalized before all statement handles
have been finalized

* fix(sqlite/test): make `concurrent_resets_dont_segfault` runtime-agnostic

Co-authored-by: link2xt <link2xt@testrun.org>
Co-authored-by: Adam Cigánek <adam.ciganek@gmail.com>
2021-08-16 14:39:45 -07:00
Atkins
55c603e9e7
build(deps): bump git2 from 0.13.19 to 0.13.20 (#1362)
Signed-off-by: Atkins Chang <atkinschang@gmail.com>
2021-08-07 01:48:10 -07:00
Atkins
9f7205e80f
Fix GitHub Actions and integration test (#1346)
* fix test suite

* rustfmt

* need Row

* test: fix integration test scripts and update the upstream supported databases

Signed-off-by: Atkins Chang <atkinschang@gmail.com>

* ci(actions): update supported databases

Signed-off-by: Atkins Chang <atkinschang@gmail.com>

* ci(actions): use `pg_isready` instead of `sleep` to avoid error cause by database not ready

Signed-off-by: Atkins Chang <atkinschang@gmail.com>

* feat(core): add `trait PgConnectionInfo` for connection parameter status from server

Signed-off-by: Atkins Chang <atkinschang@gmail.com>

* test(postgres): fix integration test for postgres

Signed-off-by: Atkins Chang <atkinschang@gmail.com>

* test(mysql): fix integration tests

Signed-off-by: Atkins Chang <atkinschang@gmail.com>

* ci(actions): test database against the oldest and newest supported versions

Signed-off-by: Atkins Chang <atkinschang@gmail.com>

* docs(core): document `trait PgConnectionInfo`

Signed-off-by: Atkins Chang <atkinschang@gmail.com>

Co-authored-by: Montana Low <montanalow@gmail.com>
2021-07-28 14:00:34 -07:00
Daniel Faust
f0d0dce8e2
Use postgres as maintenance db unless maintaining postgres itself (#1339)
Fixes #1283.
2021-07-23 16:39:25 -07:00
Luca Palmieri
34db44bffd
Mark the original DatabaseError as source. (#1197) 2021-07-23 16:31:49 -07:00
Austin Bonander
a8544fd503
fix(pg_money): handle negative values correctly in PgMoney::from_decimal() (#1334)
closes #1321
2021-07-21 16:29:20 -07:00
Austin Bonander
531740550f
fix(pool): reimplement pool internals with futures-intrusive (#1320) 2021-07-21 16:28:44 -07:00
marshoepial
cb3ff28721
Keep track of column typing in SQLite EXPLAIN parsing (#1323)
* NewRowid, Column opcodes, better pointer handling

* Implement tracking of column typing on sqlite explain parser

* fmt for sqlite column typing for explain parsing

Co-authored-by: marshoepial <marshoepial@gmail.com>
2021-07-21 16:27:47 -07:00
Austin Bonander
8bcac0394f
fix(mysql): implement type traits for chrono::DateTime<Local> (#1335)
closes #1222
2021-07-21 16:27:00 -07:00
nomick
be189bd11e
Support MACADDR in Postgres (#1329) 2021-07-19 16:55:53 -07:00
Akhil Velagapudi
0abbcc510f
Update crc 1.8.1 -> 2.0.0 (#1256) 2021-07-16 15:25:32 -07:00
Ryan Leckey
694a2ac478 release: v0.5.5 2021-05-24 09:34:34 -07:00
Ryan Leckey
5d9c292132 release: v0.5.4 2021-05-22 16:38:54 -07:00
Eamon Caton
b391d4878e Revert webpki version bump to keep compatability with tokio-rustls feature 2021-05-22 11:03:01 -07:00
Ryan Leckey
13f7c7124a release: v0.5.3 2021-05-21 17:27:15 -07:00
Ryan Leckey
2d38332137 fix: bring back accidentally removed methods on the Migrate trait as deprecated 2021-05-21 17:16:22 -07:00
Nathan Roach
db09cb61e5 Adding Any support for Local chrono datetime for MySQL 2021-05-21 16:46:41 -07:00
Guy Lapid
18acba2358 Added any types for binary blobs and chrono NaiveDateTime 2021-05-21 16:46:26 -07:00
Rafael Epplée
0acb0e5eff
Add docs for rename_all attribute for Type derive macro (#1212)
* add missing closing bracket in doctest

* document rename_all attribute for Type derive
2021-05-21 16:12:16 -07:00
Austin Bonander
8f1d8c7e2f
more pool fixes (#1211)
* a task that is marked woken but didn't actually wake before being cancelled will instead wake the next task in the queue

* a task that wakes but doesn't get a connection will put itself back in the queue instead of waiting until it times out with no way to be woken

* the idle reaper now won't run if there are tasks waiting for a connection, and also uses
the proper `SharedPool::release()` to return validated connections to the pool so waiting tasks get woken

closes #622, #1210

(hopefully for good this time)

Signed-off-by: Austin Bonander <austin@launchbadge.com>
2021-05-17 19:24:40 -07:00
Feike Steenbergen
78a94240e6
Skip empty and commented pgpass entries (#1216)
While running an application a lot of warnings were printed about my
pgpass file, like:

	Malformed line in pgpass file

This was due to the fact that my pgpass file contains whitespace and
comments to organize it in a better way.

This commit ensures we will ignore empty lines and lines that (barring
whitespace) start with a comment. This is in line with how PostgreSQL
treats these entries in the pgpass file:

- https://www.postgresql.org/docs/current/libpq-pgpass.html
- function passwordFromFile in src/interfaces/libpq/fe-connect.c
2021-05-10 16:18:13 -07:00
link2xt
405474b575
sqlite: add SqliteConnectOptions::shared_cache() (#1177)
This makes it possible to open database in shared cache mode without
having to construct `sqlite://` URL with `?cache=shared` flag.
2021-04-27 18:35:45 -07:00
Josh Triplett
b5928f6e7f Export SqliteAutoVacuum so it can be used 2021-04-27 12:35:58 -07:00
Josh Triplett
d4a7217a56 Support setting sqlite page_size
The page size setting only takes effect if set before doing anything
else to the database.
2021-04-27 12:35:23 -07:00
link2xt
fda55fe3b3 sqlite: export SqliteLockingMode
This makes it possible to `use sqlx::sqlite::SqliteLockingMode`.
2021-04-16 18:25:07 -07:00
Ryan Leckey
f7775f7fde release: 0.5.2 2021-04-15 18:40:46 -07:00
Jonas Platte
73d35e73a6 Remove Self: Type bounds in Encode / Decode implementations 2021-04-15 18:27:13 -07:00
Jonas Platte
81ae756e86 Fix warnings 2021-04-15 18:27:13 -07:00
Ryan Leckey
9e8e334697
chore: add std_rng to rand 2021-04-09 15:48:19 -07:00
Ryan Leckey
633a662752 chore: update dependencies 2021-04-09 00:31:07 -07:00
Alexander Krotov
78656eb469 fix(sqlite): reset the statement when fetch_many() stream is dropped
Unlike `Executor.fetch_optional()`, `Executor.fetch_many()` does not
have a single exit.  The stream can be dropped at any time.  To catch
this event, we create a `StatementResetter` structure inside the stream
loop and reset the statement when it is dropped.

A test case `it_resets_prepared_statement_after_fetch_many` is
similar to `it_resets_prepared_statement_after_fetch_one` which tests
`Executor.fetch_optional()`.
2021-04-09 00:23:17 -07:00
link2xt
5cf1af2d19 fix(sqlite): do not ignore API misuse errors from sqlite3_finalize 2021-04-09 00:21:52 -07:00
link2xt
f488f53916 fix(sqlite): do not cast pointers to i32
64-bit pointers can't be casted to i32 correctly.

It does not seem to cause problems on amd64 as long as both pointers
reside in the same page, but it's not correct generally.
2021-04-09 00:21:12 -07:00
argv-minus-one
2123d9de2e Make the bounds on Connection::transaction less strict.
The provided callback doesn't need to be `'static`. It should be enough that it doesn't borrow anything from the `Connection` itself, even if it does borrow data from elsewhere.
2021-04-09 00:13:51 -07:00
Ryan Leckey
fd828fed14 Merge remote-tracking branch 'demurgos/domain-type-description' 2021-04-08 23:59:25 -07:00
Diggory Blake
a3b73f8e08 Remove all listeners before returning a connection to the pool 2021-04-08 23:54:10 -07:00
Diggory Blake
01bef75cb9 Fix bug when a read on a BufStream is cancelled. 2021-04-08 23:53:45 -07:00
Josh Triplett
c96bcd9f6b Support the sqlite auto_vacuum pragma 2021-04-08 23:52:34 -07:00
Josh Triplett
62e58f5b1c Support the sqlite locking_mode pragma
This allows applications that never use a sqlite database concurrently
to avoid using shared memory for the write-ahead log.
2021-04-08 23:52:34 -07:00
Evgeny Nosov
e4dd1c3a1d Ignore reversing migrations in migrate! macro 2021-04-08 23:50:39 -07:00
Evgeny Nosov
8b866bb23d Fix migrate! macro 2021-04-08 23:50:39 -07:00
Evgeny Nosov
85ff651ba1 Add ignore_missing parameter 2021-04-08 23:50:39 -07:00
Evgeny Nosov
8950332ca3 Rewrite migration algorithm in order to apply also unapplied migrations 2021-04-08 23:50:39 -07:00
Tom Dohrmann
7463cdaf45 rename test to tests
Co-authored-by: Jonas Platte <jplatte@users.noreply.github.com>
2021-04-08 23:47:35 -07:00
Tom Dohrmann
47253d5d20 move pgpass functions into seperate submodule 2021-04-08 23:47:35 -07:00
Tom Dohrmann
88ee528f24 prefer PGPASSFILE over default paths 2021-04-08 23:47:35 -07:00
Tom Dohrmann
ea7cc78445 move tests into submodule 2021-04-08 23:47:35 -07:00
Tom Dohrmann
4c28cd5c50 fix test 2021-04-08 23:47:35 -07:00
Tom Dohrmann
ac4a9c3c1d run cargo fmt 2021-04-08 23:47:35 -07:00
Tom Dohrmann
9ccf030248 add support for pgpass files 2021-04-08 23:47:35 -07:00
Austin Bonander
5295ff10a5 fix: pool internals improvements
* fix `DecrementSizeGuard::drop()` only waking one `Waiter` regardless of whether that waiter was already woken
* fix connect-backoff loop giving up the size guard
* don't cut in line to open a new connection
* have tasks waiting on `acquire()` wake periodically to check if there's a connection in the queue

Signed-off-by: Austin Bonander <austin@launchbadge.com>
2021-04-06 09:04:20 -07:00
crajcan
469c4ac130
Correct Postgres' Length Limit for Bind Parameters (#1141)
* Bump limit for postgres' bind parameters

* Fix lingering fmt error
2021-03-29 19:39:27 -07:00
Charles Samborski
93b90be9f7 fix(postgres): Add support for domain types description
Fix commit updates the `postgres::connection::describe` module to add full support for domain types. Domain types were previously confused with their category which caused invalid oid resolution.

Fixes launchbadge/sqlx#110
2021-03-16 20:23:03 +01:00
Rich Murphey
edcc91c9f2
replace deprecated compare_and_swap() with compare_exchange() (#1080) 2021-03-03 08:50:12 -08:00
Nathan Roach
d5f9f08c62 Fixing NaiveTime not including SQLite 2021-02-27 01:24:25 -08:00
Nathan Roach
4b5f41eebe Fixing format, removing duplicate NaiveDate 2021-02-27 01:24:25 -08:00
Nathan Roach
9d6c5defd4 Adding derivation of any types for chrono types present in all of the featured sql types at compile time 2021-02-27 01:24:25 -08:00
Jonas Platte
e8f4eebdbe Make re-exports from other crates show up as such
… in `types` and sub-modules.
2021-02-27 01:22:22 -08:00
mareq
111265b5ab doc: Add information on the required structure of the migration scripts 2021-02-27 01:06:17 -08:00
Austin Bonander
0ed524d65c fix(pool): always ping connection on release to see if it's still viable
Signed-off-by: Austin Bonander <austin@launchbadge.com>
2021-02-27 00:56:08 -08:00
Austin Bonander
1a9e0d9a52 ban Ord::{min, max} with Clippy as it's too easy to misread
It is *much* too easy to misread `x.min(y)` as "`x` should be *at least* `y`" when in fact it means the *exact* opposite, and same with `x.max(y)`. This has bitten us in the gluteus maximus a number of times both in SQLx and in private projects.

Signed-off-by: Austin Bonander <austin@launchbadge.com>
2021-02-05 13:30:35 -08:00
Ryan Leckey
cbe820760f
release: 0.5.1 2021-02-04 09:16:11 -08:00
Ryan Leckey
efccd6c9b8
chore: update sqlx-rt to 0.3 2021-02-04 09:15:00 -08:00
Ryan Leckey
94d0baeb52
release: 0.5 2021-02-04 06:32:50 -08:00
Ryan Leckey
2fd26b5504
sqlite: remove support for u64
see https://github.com/launchbadge/sqlx/pull/919#discussion_r557106441
2021-02-04 06:17:17 -08:00
wuaoxiang
31abe22e34 fix(sqlite): GROUP BY in query! cause infinite loop at compile time 2021-01-31 16:58:48 -08:00
Jonas Platte
6fea00304e Remove any::AnyType
It was not actually used in a meaningful way.
2021-01-31 16:56:37 -08:00
Jonas Platte
1b217cfac4 Make impl Acquire for &'_ Pool<DB> more general 2021-01-31 16:54:22 -08:00
Jonas Platte
77238108cf Require Acquire::Connection to be Send 2021-01-31 16:54:22 -08:00
Ryan Leckey
df393128f8
style: rustfmt 2021-01-20 22:29:05 -08:00
Austin Bonander
89305873b0
fix(postgres): patch nullable inference in Postgres using EXPLAIN
BREAKING CHANGE: some columns in `query!()` et. al. output will change from `T` to `Option<T>`

breakage should be minimal in practice as
these columns will need to have been manually
overridden anyway to avoid runtime errors

Signed-off-by: Austin Bonander <austin@launchbadge.com>
2021-01-20 22:27:44 -08:00
Austin Bonander
5e452d9e86
fix(sqlite): remove errant println!() in sqlite/explain.rs 2021-01-20 22:26:43 -08:00
Austin Bonander
7c32928ebc
feat(macros): implement query_scalar!() and variants
Signed-off-by: Austin Bonander <austin@launchbadge.com>
2021-01-20 22:23:04 -08:00
Ryan Leckey
b0c430ed18
feat(sqlite): track nullable through left joins 2021-01-20 22:22:26 -08:00
Sho Nakatani
0c0dd6936a feat: Adds Debug, Clone auto-derive to SqliteArguments 2021-01-20 22:15:48 -08:00
William Hammond
25858fc42a Improves error handling in the case of missing type 2021-01-20 22:10:03 -08:00
Ryan Leckey
e03c31adcd
Merge branch 'feature/inline-certificates' of https://github.com/alex-berger/sqlx into alex-berger-feature/inline-certificates 2021-01-20 22:08:26 -08:00
Florian Hübsch
68cf2f9cdb Add constraint method to DatabaseError trait
Override `constraint` method for `PgDatabaseError`.
2021-01-20 22:00:44 -08:00
Ryan Leckey
d5e0f1b92b
refactor: rename DbOutcome to DbQueryResult 2021-01-20 21:57:26 -08:00
Jonas Platte
c5d43db312
Upgrade async runtime dependencies
Co-authored-by: Josh Toft <joshtoft@gmail.com>
Co-authored-by: Philip A Reimer <antreimer@gmail.com>
2021-01-20 21:50:45 -08:00
Ryan Leckey
de4a7decfb
fix(sqlite): i64 -> u64 in type docs 2021-01-20 21:50:45 -08:00
dignifiedquire
1d87b6cc8d
feat: implement unsigned int support for sqlite 2021-01-20 21:50:45 -08:00
Takeru Ohta
a6aef7817b
fix to read just 20 bytes for AuthSwitchRequest data 2021-01-20 21:50:44 -08:00
Jonas Platte
08a76f45ae
Rename DbDone to DbOutcome 2021-01-12 14:45:01 +01:00
Jonas Platte
a1d562f04b
Remove the Done trait 2021-01-12 14:37:44 +01:00
Jonas Platte
e2f7aa2eca Restore support for sqlx(rename) on types, with a deprecation warning 2021-01-12 03:39:10 -08:00
Jonas Platte
fd8b2b7f8a Rename sqlx(rename) attribute to sqlx(type_name) 2021-01-12 03:39:10 -08:00
Jonas Platte
74835bfe58
Allow chaining map / try_map on queries
To support `.map()` / `.try_map()` on `query!()` (and `query_as!()`).
2021-01-05 23:50:27 -08:00
Jonas Platte
9eca6413fe
Remove TryMapRow and MapRow
These traits were a workaround for a bug in rustc that an earlier
revision of the API triggered, but the API has since been changed.
2021-01-05 23:50:23 -08:00
Chloe Ross
2890d154a3 doc: use the fancy new intra-crate doc links everywhere 2021-01-04 18:39:03 -08:00
Austin Bonander
ef6c73c985 doc: add tables describing the right method to call on query!() et al
Signed-off-by: Austin Bonander <austin@launchbadge.com>
2021-01-04 12:03:42 -08:00
up9cloud
e7eaed6220 remove unnecessary Fut 2021-01-04 09:31:47 -08:00
Austin Bonander
93ba3d59e7 fix(logging): make query logging obey level setting for sqlx::query target
Signed-off-by: Austin Bonander <austin@launchbadge.com>
2020-12-29 15:28:06 -08:00
Kirill Bulatov
24c85d20d6 Add a way to disable query logging programmatically 2020-12-29 11:30:34 -08:00
Jakob Truelsen
9146929575 Do not attempt to reconnect on every Io error.
Io errors can describe a lot of things, when connecting to a database in general only
ECONNREFUSED can be hoped to be resolved by waiting. Other errors will require
user intervention
2020-12-25 19:36:54 -08:00
Jakob Truelsen
46f9f44d41 Do not call connect it a bussy loop on connection refused.
If the connection to the database is refused, it is not helpfull to hammer it with connection
attempts, instead we should wait a bit before connecting again. Here we start waiting 10ms,
doubling the wait time for every attempt before setteling out at 2s
2020-12-25 19:36:54 -08:00
Brandon
b8839c6d90 Convert to intra-crate links 2020-12-23 18:49:39 -08:00
Brandon
cbc1deb363 Fix broken link in Transaction docs 2020-12-23 18:49:39 -08:00
Jakob Truelsen
c7cf104a8f Handle dropping wait_for_conn
If wait_for_conn is dropped before completing, release will call
wake on a waker that noone is listining on. This leads to a state where
waiting will gro indefinitly while all connections are idle.

To fix this we turn waiting into a queue of unique Weak pointers.
This way if wait_for_conn is dropped the pointer in waiting cannot
be upgraded, we can use this as a signal that we shoud wake the
next one instead.
2020-12-22 20:13:40 -08:00
Ryan Leckey
565d0a91a3
release: v0.4.2 2020-12-19 01:07:50 -08:00
Ryan Leckey
2d3b9e4909
fix: rollback (another) update to rustls 2020-12-19 00:37:45 -08:00
Ryan Leckey
7bbf89c301
fix: rollback a couple package updates (forgot to check tokio) 2020-12-19 00:34:10 -08:00
Ryan Leckey
c410f88bcd
chore: update several dependencies 2020-12-19 00:26:06 -08:00
Ryan Leckey
e9e1dcf78e
style: rustfmt 2020-12-19 00:08:29 -08:00
Ryan Leckey
00d3211f03
add runtime-async-std-native-tls to docs.rs feature in sqlx-core 2020-12-18 23:30:29 -08:00
Ryan Leckey
405553cc43
Merge branch 'slumber-another-fix-for-decimals' of https://github.com/slumber/sqlx into slumber-slumber-another-fix-for-decimals 2020-12-18 23:23:06 -08:00
Mike Cronce
376ea3f596 sqlx-core/src/mysql/types/str.rs: + COLLATE_UTF8MB4_GENERAL_CI 2020-12-19 07:17:28 +00:00
Hamza
d1417dc2ec Ensure tests pass 2020-12-19 07:17:12 +00:00
Hamza
8a55ae2d32 Fix transaction wrapper 2020-12-19 07:17:12 +00:00
Federico Rampazzo
b9e57de005 Rename mixedCase to camelCase, CamelCase to PascalCase, aligning with serde 2020-12-19 07:14:09 +00:00
Federico Rampazzo
aa0adaa434 Updated rename-all docs 2020-12-19 07:14:09 +00:00
Marcin Kaźmierczak
e584618041 sqlite synchronous setting 2020-12-19 06:03:50 +00:00
Ryan Leckey
4ee1727ba6
fix: tweak bstr and git2 Encode impls 2020-12-18 21:56:29 -08:00
Eric Semeniuc
389f9b5f41
fix macro 2020-12-18 21:33:52 -08:00
Eric Semeniuc
7cc0ecb981
Add cfg sqlite condition 2020-12-18 21:33:52 -08:00
Eric Semeniuc
c64b9bee45
Address pr feedback 2020-12-18 21:33:51 -08:00
Eric Semeniuc
892bbc95a9
add new example for migration 2020-12-18 21:33:51 -08:00
Ryan Leckey
187b7481e9
fix(sqlite): implement Encode on Uuid and Hyphenated not references to them 2020-12-18 21:33:50 -08:00
James Tomlinson
7c8822ae5e
Fix formatting (cargo fmt) 2020-12-18 21:33:30 -08:00
James Tomlinson
40011f66df
Uuid support for Sqlite.
Includes the same support for the Hyphenated adapter as the MySQL
Uuid support.
2020-12-18 21:33:30 -08:00
Andrew Whitehead
a445f9f431
manually close connections in SharedPool::close 2020-12-18 21:33:11 -08:00
Andrew Whitehead
f39d194b17
decrement pool size when connection is released 2020-12-18 21:33:11 -08:00
Chris Sosnin
4c1cf86380
sqlite: fix memory leak 2020-12-18 21:33:11 -08:00
Fangdun Cai
169fb298ef
fix: whoami crash on FreeBSD aarch platform 2020-12-18 21:33:11 -08:00
chertov
6f793271c4
Replace lru-cache with hashlink 2020-12-18 21:33:09 -08:00
Marcin Kaźmierczak
9ad0c71253
fix clipyy warnings 2020-12-18 21:32:08 -08:00
sid
0921df44c1
reversible migrations for cli
- adds a -r flag whihc will create a reversible migration
- add revert subcommand, which reverts the last migration
- add --dry-run flag to migration run command, which list the migrations that will be applied
- updates add migration to check if all migration are of same type, i.e cannot mix and match reversible and simple migrations
2020-12-18 21:32:08 -08:00
Marcin Kaźmierczak
e798409e20
fix fetch_optional for sqlite 2020-12-18 21:32:08 -08:00
Chris Sosnin
9747218ad3 postgres: fix decimal conversions 2020-12-10 22:22:33 +03:00
Chris Sosnin
82b66b29a3 Revert "Fixing BigDecimal conversion for PostgreSQL"
This reverts commit a0007b4e98.
2020-12-10 22:02:01 +03:00
chertov
04647ae09a Replace lru-cache with hashlink 2020-12-02 18:41:49 -08:00
alex.berger@nexiot.ch
8379728d6e fix formatting 2020-11-27 17:58:05 +01:00
alex.berger@nexiot.ch
6ecdb83bc2 Add support for passing in-memory trusted certificates in addition to the already supported path to trusted certificates. 2020-11-27 17:43:24 +01:00
Marcin Kaźmierczak
7f1bff406d fix clipyy warnings 2020-11-24 16:15:22 -08:00
sid
f41551f3ad reversible migrations for cli
- adds a -r flag whihc will create a reversible migration
- add revert subcommand, which reverts the last migration
- add --dry-run flag to migration run command, which list the migrations that will be applied
- updates add migration to check if all migration are of same type, i.e cannot mix and match reversible and simple migrations
2020-11-24 16:04:43 -08:00
Marcin Kaźmierczak
70fa667063 fix fetch_optional for sqlite 2020-11-24 16:01:52 -08:00
Josh Triplett
71a72e7c67 Add support for git2::Oid (under the git2 feature flag)
This allows queries to convert between Oid and SQL data types.
2020-11-21 14:32:29 -08:00
Josh Triplett
47b0973bdb Add support for bstr::BString (under the bstr feature flag)
This allows queries to convert between BString and SQL data types.
2020-11-21 14:03:11 -08:00
Jonas Platte
c1e79d2675 Simplify pattern matching in postgres/type_info.rs 2020-11-19 14:04:07 -08:00
Jonas Platte
3c7c266eac Fix some clippy lints 2020-11-19 14:04:07 -08:00
Ryan Leckey
0b03dc6762 prepare v0.4.0 2020-11-12 07:46:13 -08:00
Ryan Leckey
f22a3f5a5d remove default runtime, you must now always select a runtime 2020-11-12 07:42:31 -08:00
Jonas Platte
1ed75ba5f0 Support accept_invalid_certs & accept_invalid_hostnames with rustls
Co-authored-by: BlackHoleFox <blackholefoxdev@gmail.com>
2020-11-12 07:32:59 -08:00
Jonas Platte
b14266ba2e Add rustls support 2020-11-12 07:32:59 -08:00
Jonas Platte
9298c88b87 Refactor TLS code to be a bit easier to read 2020-11-12 07:32:21 -08:00
Jonas Platte
cd44b5eb43 De-duplicate mysql & postgres TLS code 2020-11-12 07:32:21 -08:00
Jonas Platte
a161bcba05 Rename cargo features in preparation for rustls support 2020-11-12 07:32:21 -08:00
Ryan Leckey
b8bce0a541 Merge branch 'mysql-non-ascii-credentials' of https://github.com/yerke/sqlx into yerke-mysql-non-ascii-credentials 2020-11-12 07:21:10 -08:00
Austin Bonander
cebfcce1b5 docs: WIP improve docs about Pool
Signed-off-by: Austin Bonander <austin@launchbadge.com>
2020-11-12 07:15:08 -08:00
Jakob Truelsen
9d71a7f372 Allow configuring the log level of query logging 2020-11-12 07:06:34 -08:00
David Yamnitsky
12b4250454 support sqlite bind parameters of the form $NNN 2020-11-06 15:08:08 -08:00
Yerkebulan Tulibergenov
b2ee575e4f Merge branch 'master' into mysql-non-ascii-credentials 2020-11-04 22:50:03 -08:00
Julius de Bruijn
a0007b4e98 Fixing BigDecimal conversion for PostgreSQL
Now working properly with numbers, such as `0.01` and `0.012`.
2020-11-04 17:09:01 -08:00
Julius de Bruijn
25e72925fa Update to bigdecimal 0.2 and num-bigint 0.3 2020-11-04 17:09:01 -08:00
Marcin Kaźmierczak
1d9ab5245c use futures_channel::oneshot in sqlite worker 2020-11-03 22:51:42 -08:00
Jonas Platte
85b5ab0fb3 Fix cfg-specific unused lints 2020-10-29 22:21:27 -07:00
Austin Bonander
e44031676f doc: improve docs for Type and FromRow derives 2020-10-29 18:33:14 -07:00
dignifiedquire
eae3f46237 update libsqlite3-sys to 0.20 2020-10-26 01:34:28 -07:00
Peter Maatman
fae72200e5 sqlite: Add basic json implementation
Fixes #608
2020-10-20 20:08:20 -07:00
Daniel Stöckel
144dcceb44 fix(postgres): prefer parsing non-localized notice severity field
In order to support PostgreSQL <= 9.5, the b'S' field of an error/notice
message was parsed. However, this field can be localized and thus parsing
can fail for instances that use a non-english locale. In version > 9.5,
the b'V' field, that is guaranteed to be in english, was added. However,
even for these versions parsing would fail as the b'S' field was also
parsed. This patch prefers b'V' over b'S' if it exists and uses a default
severity in case b'V' is not present and b'S' could not be parsed.

Fixes #734
2020-10-19 00:03:06 -07:00
Dana Marcuse
d97014f620 feat: correctly handle percent-encoded socket as host for postgres URI 2020-10-18 01:19:11 -07:00
Dana Marcuse
7b1b8c12ba feat: handle hostaddr postgres URI param and add more tests 2020-10-18 01:19:11 -07:00
Joshua Nelson
591d33b877 Enable all features for sqlx-core on docs.rs 2020-10-17 02:44:53 -07:00
Joshua Nelson
20d65a8248 Remove hashbrown dependency
Hashbrown is now the hashmap used in the standard library, so no need to
pull in an external dependency. This switches to using `AHashMap`
directly.
2020-10-17 02:44:09 -07:00
Rodrigo Araujo
d69d897eab Remove last line 2020-10-16 17:31:30 -07:00
Rodrigo Araujo
ce4b8caaa2 Format code 2020-10-16 17:31:30 -07:00
Rodrigo Araujo
f808a81f6c TiDB compatibility: Add support to utf8mb4_bin collation 2020-10-16 17:31:30 -07:00
Jonas Platte
e1662e42e1 Fix unused variable warnings in migrate.rs with feature = "mssql" 2020-10-16 14:49:27 -07:00
Gevorg Hindoyan
5835bc4951 Fix NaiveDate parse_from_str argument order
The [documentation](https://docs.rs/chrono/0.4.13/chrono/naive/struct.NaiveDate.html#method.parse_from_str) specifies that `NaiveDate::parse_from_str` takes two arguments: value and format, in respective order. 

Due to this, `DATE` fields could not be read into `NaiveDate`... and I have ptsd.
2020-10-16 14:40:50 -07:00
Mike Cronce
fd25a7530c sqlx-core/src/mysql/protocol/statement/execute.rs: Execute::encode_with(): Encode a 1 for iteration-count instead of 0 2020-10-15 22:51:08 -07:00
Austin Bonander
fa7981f68a fix(pool): ignore spurious wakeups when waiting for a connection
fixes #622
2020-10-13 10:37:10 -07:00
Julius de Bruijn
7a70717944 Use flags to detect MySQL enums
In some cases the returned value is of `ColumnType::String`, but it has
the `ENUM` flag set.
2020-10-13 10:09:06 -07:00
Jonas Platte
1935e91e7a Bump base64 version 2020-10-13 10:04:05 -07:00
Jonas Platte
63bfab90c5 Bump hmac version 2020-10-13 10:04:05 -07:00
Jonas Platte
f155bb83e8 Bump hashbrown version 2020-10-13 10:04:05 -07:00
Joshua Nelson
920168a129 Add examples to after_connect documentation
This requires testing with `--features postgres`.
2020-10-13 10:02:24 -07:00
Joshua Nelson
2be4601150 Add size() and num_idle() 2020-10-13 09:57:56 -07:00
Kramer Hampton
d0ccb4d0b2 feat: parse additional parameters: user, password, port, dbname. Also
add additional documentation and an example connection string using
parameters.
2020-10-13 09:56:48 -07:00
Wesley Norris
727ebf0b38 Percent decode MySQL passwords from URL string
Fixes #603.
Adds percent decoding for MySQL passwords for when they contain non-URL
safe passwords, along with a regression test to prevent further
instances of this issue.
2020-10-13 09:55:40 -07:00
Patryk Wychowaniec
ca07158949 sqlite: Fix #616 2020-10-13 09:54:50 -07:00
Jonas Platte
3b9c98d979 Fix bounds for F on query::Map
Query::map was not usable before.
2020-10-13 09:50:34 -07:00
Jonas Platte
4ad4a42edd Make Send a supertrait of TryMapRow, MapRow
Map<'q, DB, F, A> where F: !Send was useless and these traits are only
used as part of Map. This might improve error messages.
2020-10-13 09:50:34 -07:00
Chris Couzens
8e4d061dc1 Correct PgConnectOptions to MySql in mysql docs
I'm using this library for the first time, and I noticed this small oversight in the docs.
2020-10-07 05:24:03 -07:00
David Yamnitsky
44594e2e03 impl From for AnyConnectOptions 2020-09-09 01:18:28 -07:00
Mike Cronce
1acd782e7f sqlx-core/src/mysql/types/str.rs: cargo fmt 2020-09-02 22:53:13 -07:00
Mike Cronce
d8142a8fa3 sqlx-core/src/mysql/types/str.rs: str::compatible(): Added support for charset number 33 (utf8 COLLATE utf8_general_ci) 2020-09-02 22:53:13 -07:00
Andrew Whitehead
9cd9209aa3 add support for pooling in-memory sqlite DB, enabling shared cache 2020-09-02 22:51:03 -07:00