Commit graph

433 commits

Author SHA1 Message Date
Paolo Barbolini
ec15f6b30c
Update uuid crate to v1 (#1821) 2022-04-20 12:48:29 -07:00
Atkins
17760d0f83
Move server_version_num from trait to impl (#1384)
* refactor(core): move `fn server_version_num` from `trait PgConnectionInfo` to impl

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

* fix rebase issues

Co-authored-by: Austin Bonander <austin@launchbadge.com>
2022-04-14 16:02:08 -07:00
Paolo Barbolini
ba123e62fa
Update time to 0.3.2 (#1455)
Co-authored-by: Tyler Hill <tyhi@tyhi.rs>
2022-04-14 15:11:46 -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
05storm26
f328cc15d8
Sqlite chrono::DateTime<FixedOffset> timezone fix (#1618) 2022-04-14 15:06:55 -07:00
tyrelr
217dc55062
Fix #1249 Left joins in SQLite can break the query macros (#1789)
* Reproduce github issue#1249: Left joins in sqlite can break the query macros

* Fix panic caused by unknown cursor columns when executing NullRow command. Fixes #1249
2022-04-07 13:18:37 -07:00
Austin Bonander
f1c635d739
feat(pool): implement close-event notification (#1776)
fix(postgres): integrate pool close-event into `PgListener`

closes #1764
2022-04-05 16:17:35 -07:00
Austin Bonander
e1817f0a9d
feat: convenient wrapper for Postgres advisory locks (#1641) 2022-03-24 17:38:24 -07:00
Carol (Nichols || Goulding)
f5392151f3
Derive PgHasArrayType for transparent sqlx types (#1748)
Fixes #1744.
2022-03-23 16:41:36 -07: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
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
Austin Bonander
7fd324d337
fix(ci): pin MySQL version in the correct place 2022-02-11 12:55:23 -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
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
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
Paolo Barbolini
f2b3cc8dc3
ci: test on Postgres 14 (#1557) 2021-11-29 12:58:19 -08: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
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
1b5dd6514b
preparing 0.5.8 release (#1466)
* preparing 0.5.8 release

* fix warnings before release
2021-10-01 14:45:25 -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
6e1c7a999a
Update postgres 14 test to 14rc1 (#1454) 2021-09-24 11:33:36 -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
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
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
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
Austin Bonander
e89cb0971a
fix(macros): tell the compiler about external files/env vars to watch (#1332)
* fix(macros): tell the compiler about external files/env vars to watch

closes #663
closes #681

* feat(cli): add `migrate` subcommand for generating a build script

suggest embedding migrations on `sqlx migrate add` in a new project
2021-07-21 16:36:22 -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
nomick
be189bd11e
Support MACADDR in Postgres (#1329) 2021-07-19 16:55:53 -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
link2xt
bd06836fba test(sqlite): extend it_caches_statements() test
Test that initial PRAGMA statements and &str statements are not
cached, but sqlx::query() statements are cached by default.
2021-04-15 18:26:06 -07:00
Ryan Leckey
98cd619157 style: rustfmt 2021-04-09 00:24:14 -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
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
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
Ryan Leckey
b6e1275617
fix: derive(Type) should emit a forwarded impl for the compatible function 2021-03-18 16:12:00 -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
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
Jonas Platte
2b2418c6d1 Add a test for nesting .map 2021-01-31 16:57:29 -08:00
Jonas Platte
7ebd362453 Update issue_104 test to use map instead of try_map 2021-01-31 16:57:29 -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
6b036055e5
format: run rustfmt 2021-01-20 22:26:48 -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
Marcin Kaźmierczak
8328f893e4 sqlite test - prepared statements are reset after fetch_one 2021-01-20 22:10:59 -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
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
Jonas Platte
a1d562f04b
Remove the Done trait 2021-01-12 14:37:44 +01:00
Jonas Platte
fd0101afb2 Update some postgres trybuild tests 2021-01-12 03:39:10 -08:00
Jonas Platte
b3f78b8255 Add a trybuild test for sqlx(rename) 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
Ryan Leckey
e9e1dcf78e
style: rustfmt 2020-12-19 00:08:29 -08:00
Federico Rampazzo
c416c94d43 Fix escaping test query 2020-12-19 07:14:09 +00:00
Federico Rampazzo
3a7fe4da94 Fix more typos 2020-12-19 07:14:09 +00:00
Federico Rampazzo
0bb5e92836 Fix typo 2020-12-19 07:14:09 +00:00
Federico Rampazzo
05e42a8cac Cargo fmt 2020-12-19 07:14:09 +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
00a999145f Add mixedCase and CamelCase to rename-all, added rename-all to FromRow 2020-12-19 07:14:09 +00:00
Ryan Leckey
4f261b7346
test: added an explicit cast for bstr test where sqlite failed to do an implicit cast 2020-12-18 21:56:50 -08:00
Ryan Leckey
58618f62a2
fix(tests): update x.py with new runtime-* features 2020-12-18 21:33:51 -08:00
James Tomlinson
a959451e85
Add Sqlite Uuid type tests. 2020-12-18 21:33:49 -08:00
Josh Triplett
603c1950fe Add tests for git2 2020-11-21 14:32:29 -08:00
Josh Triplett
d396e5a948 Add tests for bstr 2020-11-21 14:32:29 -08:00
Jonas Platte
a161bcba05 Rename cargo features in preparation for rustls support 2020-11-12 07:32:21 -08:00
David Yamnitsky
12b4250454 support sqlite bind parameters of the form $NNN 2020-11-06 15:08:08 -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
333ee69f63 A test to reveal a bug with BigDecimal and PostgreSQL 2020-11-04 17:09:01 -08:00
dvermd
964837e255 Add #[derive(FromRow)] for tuple struct 2020-10-26 01:33:59 -07:00
Peter Maatman
5b7f3ab0e3 sqlite: Add test for JSON functions 2020-10-20 20:08:20 -07:00
Peter Maatman
fae72200e5 sqlite: Add basic json implementation
Fixes #608
2020-10-20 20:08:20 -07:00
Siddhant
65de83aff8 Fixed test cases 2020-10-20 15:13:18 -07:00
Siddhant
14191da283 Edited test cases to create and drop type 2020-10-20 15:13:18 -07:00
Siddhant
497f92f602 Added test cases for kebab-case enums 2020-10-20 15:13:18 -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
Stuart Hinson
9b26d45344 application name test 2020-08-19 17:56:51 -07:00
Chloe Ross
3885ae6ddf fix: allow queries that select just void to pass through macros as () instead of struct { _1: () } 2020-07-31 04:14:48 -07:00
Jannik Obermann
67142259e4 Fix #580 + Add test 2020-07-31 04:14:32 -07:00
Julius de Bruijn
1a59d3308a Pg: Implementing BIT and VARBIT using BitVec 2020-07-27 03:36:44 -07:00
Ryan Leckey
27c67752f3 test(mysql): remove failing part of boolean describe test - not easily possible to fix in 0.4 2020-07-27 01:11:11 -07:00
Raphaël Thériault
ced09e0545
Support using both nullability and type overrides (#549)
* Make it possible to use both nullability and type overrides

* Fix override parsing lookahead logic

* Update column override tests

* Support nullability overrides with wildcard type overrides

* Fix tests

* Update query! overrides docs

* Remove last bits of macro_result!

* rustfmt
2020-07-27 00:43:35 -07:00
Ryan Leckey
d06de149a0 fix: get MatchBorrow type check working for references 3 deep 2020-07-26 23:07:12 -07:00
Ryan Leckey
3d7ac03e52 style: rustfmt 2020-07-26 22:30:45 -07:00
Ryan Leckey
4fec7db789 test(mysql, uuid): add some tests to prove UUIDs work in MySQL 2020-07-26 22:30:32 -07:00
Ryan Leckey
ec0e84d8ac feat(mysql): support reading and writing BIT via unsigned integers
e.g., BIT(64) is u64 and BIT(2) is u8
2020-07-26 19:42:32 -07:00
Ryan Leckey
7b132d1dbc refactor(mysql): store max_size in MySqlTypeInfo – prepare for an eventual future where emit bool for TINYINT(1) 2020-07-26 19:37:58 -07:00
Ryan Leckey
55f6c9a2e9 test: fix decode test in macros 2020-07-26 18:11:15 -07:00
Ryan Leckey
f298eb3cf1 Merge remote-tracking branch 'raftario/embedded-migrations' 2020-07-26 18:03:59 -07:00
Ryan Leckey
86d41f17aa Merge remote-tracking branch 'origin/ab/macro-refresh' 2020-07-26 17:54:23 -07:00
Ryan Leckey
b61c0821ab style: rustfmt 2020-07-24 08:07:44 -07:00
Ryan Leckey
3840d031c6 test: add a test case for YEAR support (as u16) 2020-07-24 08:07:07 -07:00
Ryan Leckey
08d2c79279 feat(postgres): expose PgTypeKind 2020-07-24 07:28:59 -07:00
Danny Weinberg
f0f93c4f79 Fix options in tests 2020-07-24 07:25:29 -07:00
Danny Weinberg
036bd2a05d Add SCREAMING_SNAKE_CASE rename_all option
This mirrors the addition of `uppercase` in https://github.com/launchbadge/sqlx/pull/304, but for all uppercase snake case.
2020-07-24 07:25:29 -07:00
Ryan Leckey
e575501a39 feat: add Executor::prepare, a hook into the automatic statement preparation life-cycle 2020-07-24 07:24:23 -07:00