Commit graph

1127 commits

Author SHA1 Message Date
Paolo Barbolini
171b00de2e Start testing on Postgres 15 and drop Postgres 10 (#2193)
* CHANGELOG: mention that users should upgrade CLI

* Drop postgres 10 start testing postgres 15

---------

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
2023-02-21 13:25:25 -08:00
CosmicHorror
acaee75a30 Initial work to switch to tracing (#2185)
* Add tracing dep

* Switch over basic events

* Switch over dynamically enabled events

* Fix missing SocketAddr formatting

* More format fixing

* refactor: Apply tracing changes to new crate structure
2023-02-21 13:25:25 -08:00
Danilo Cianfrone
b72a52b066 fix: use owned Builder pattern for ConnectOptions (#2132)
* CHANGELOG: mention that users should upgrade CLI

* fix(sqlx-core): use owned builder pattern for ConnectOptions

---------

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
2023-02-21 13:25:25 -08:00
Luiz Carvalho
c09532864d feat: better database errors (#2109)
* feat(core): create error kind enum

* feat(core): add error kind for postgres

* feat(core): add error kind for sqlite

* feat(core): add error kind for mysql

* test(postgres): add error tests

* test(sqlite): add error tests

* test(mysql): add error tests

* fix(tests): fix tests rebasing

* refac(errors): add `ErrorKind::Other` variant
2023-02-21 13:25:25 -08:00
OverHash
771ab80a62 Use let else statements in favor of macro (#2213) 2023-02-21 13:25:25 -08:00
Max Bruckner
092922e42a Expose PoolOptions for reading (#2113)
This allows reading back PoolOptions that have already been set.
2023-02-21 13:25:25 -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
tyrelr
f0d6924f92 avoid improper path merger if cursor backing register, or cursor emptiness is different (#2120) 2023-02-21 13:25:25 -08:00
Rongcui Dong
3cb8e07b44 Sqlite EXPLAIN type inference improvements (#1984)
* AggValue and ROW_NUMBER()

* Some more functions

* cargo fmt
2023-02-21 13:25:25 -08:00
Thomas Alton
42dd78fe93 feat: Add set_connect_options method to Pool (#2088)
* feat: Add set_connect_options method to Pool

This allows external updates of the ConnectionOptions used when a new
connection needs to be opened for the pool.  The primary use case
is to support dynamically updated (read: rotated) credentials used
by systems like AWS RDS.

* Use Arc wrapper for ConnectOptions to reduce lock contention

* sqlite fix

* Use direct assignment instead of mem::swap

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

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
2023-02-21 13:25:25 -08:00
cycraig
e5f91ab52f Fix sqlite compilation (#2098) 2023-02-21 13:25:25 -08:00
Lining Pan
75a34951ab Fix compile time verification performance regression for sqlite (#1946)
* add instruction, register, and cursor state memorization

* fix: fixed formating
2023-02-21 13:25:25 -08:00
tyrelr
d5b8c66e24 Fix sqlite update return and order by type inference (#1960)
* add failing test cases for update/delete return into

* fix regression in null tracking by improving tracking of cursor empty/full state

* add failing test case for order by column types

* Add support for SorterOpen,SorterInsert,SorterData

* add failing test case for unions

* fix range copy/move implementation

* fix wrong copy/move range

* remove calls to dbg!
2023-02-21 13:25:25 -08:00
Pekka Enberg
d23be3bfa8 Update libsqlite3-sys to 0.25.1 (#2094) 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
tyrelr
8fca76065a
Sqlite explain plan log efficiency (#2091)
* capture operation codes by reference

* use Vec instead of HashSet for results

* check logging enabled before cloning result
2022-09-12 18:22:15 -07:00
Adam Cigánek
f38c739f7f
fix: make begin,commit,rollback cancel-safe in sqlite (#2054) (#2057) 2022-09-12 18:20:27 -07:00
Marco Neumann
5e56da87e0
fix: ensure migration progress is not lost for PG, mysql and sqlite (#1991)
* fix: ensure migration progress is not lost for PG

Fixes #1966.

* fix: ensure migration progress is not lost for sqlite

This is similar to #1966.

* fix: ensure reverse migration progress is not lost for PG

See #1966.

* fix: ensure reverse migration progress is not lost for sqlite

See #1966.

* fix: ensure migration progress is not lost for mysql

This is similar to #1966.

* fix: ensure reverse migration progress is not lost for mysql

See #1966.

* test: check migration type as well

* test: extend migrations testing

* fix: work around MySQL implicit commits

* refactor: simplify migration testing
2022-09-12 17:52:04 -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
Rinat Shigapov
04884f1a1a
close unnamed portal after each executed extended query (#2081)
This allows to free server resources earlier and run the same logic as simple Query does:

"The simple Query message is approximately equivalent to the series Parse, Bind, portal Describe, Execute, Close, Sync,"
2022-09-02 17:49:31 -07:00
Richard Bradfield
20877d83fd
Add extension support for SQLite (#2062)
* Add extension support for SQLite

While SQLite supports loading extensions at run-time via either the C
API or the SQL interface, they strongly recommend [1] only enabling the C
API so that SQL injections don't allow attackers to run arbitrary
extension code.

Here we take the most conservative approach, we enable only the C
function, and then only when the user requests extensions be loaded in
their `SqliteConnectOptions`, and disable it again once we're done
loading those requested modules. We don't add any support for loading
extensions via environment variables or connection strings.

Extensions in the options are stored as an IndexMap as the load order
can have side effects, they will be loaded in the order they are
supplied by the caller.

Extensions with custom entry points are supported, but a default API
is exposed as most users will interact with extensions using the
defaults.

[1]: https://sqlite.org/c3ref/enable_load_extension.html

* Add extension testing for SQlite

Extends x.py to download an appropriate shared object file for supported
operating systems, and uses wget to fetch one into the GitHub Actions
context for use by CI.

Overriding LD_LIBRARY_PATH for only this specific DB minimises the
impact on the rest of the suite.
2022-09-01 15:03:27 -07:00
Tobias Tschinkowitz
9de70d2e7a
fix: mssql uses unsigned for tinyint instead of signed (#2074) 2022-08-31 18:10:29 -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
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
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
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
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
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
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
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
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
Thomas de Zeeuw
39eadd6d6d
Implement Clone for PoolOptions (#1919)
To not break the API we need to use an Arc instead of a Box for the
callback functions. Alternatively we could require all the function to
be Clone, but that would be a breaking change.
2022-06-22 15:00:28 -07:00
Austin Bonander
3d4861fd7c
pool: fix panic when using callbacks (#1915)
* pool: fix panic when using callbacks

add regression test

* pool: fix panic when using callbacks

add regression test

added missing typedef `MssqlPoolOptions`
2022-06-21 15:17:48 -07:00
meh
59ad2ecc92
Add support for IpAddr (#1822) 2022-06-17 17:14:47 -07:00
Romain
339e0580ca
fix #1905 : replaced all uses of "uri" to "url" (#1906)
* fix #1905 : replaced all uses of "uri" to "url"

* rebase commits

resolved conflicts in mod.rs

fixed conflict in options.rs

Update options.rs

Update options.rs

Update options.rs
2022-06-17 15:32:30 -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
Austin Bonander
f02ff94e9c
refactor: pool fixes and breaking changes (#1901)
* Fixed leak of `Arc<SharedPool>` in `DecrementSizeGuard::cancel()`
* Renamed `PoolOptions::connect_timeout` to `acquire_timeout` for clarity.
* Fixed `/* SQLx ping */` showing up in Postgres query logs
* Made `.close()` a regular function that returns a `Future`
* Deleted deprecated method `PoolConnection::release()`
* Document why connection might be dropped if `Pool::acquire()` is cancelled
* Added connection metadata to pool lifecycle callbacks
* Improved guarantees for `min_connections`
* Fixed `num_idle()` to not spin forever at high load
* Improved documentation across the `pool` module
2022-06-16 12:56:28 -07:00
Arne Beer
21590d51f5
Expose connect_options for initialized pools and database on the PgConnectOptions (#1897)
* Expose ConnectOptions

* Expose PoolOptions
2022-06-16 12:25:13 -07:00
Chengxing Yuan
edaf7d0673
Add i16 support for Any Type. (#1895)
* Add i16 support for Any Type.

* fix test.
2022-06-08 16:01:55 -07:00
Keiji, Yoshimi
185c57d936
added test for LoginAck (#1890) 2022-06-08 15:49:34 -07:00
Keiji, Yoshimi
4e9bfb0b2d
added test for mssql protocol Info (#1891) 2022-06-08 15:49:25 -07:00
Keiji, Yoshimi
3cfa734b50
added test for mssql ReturnValue (#1892)
* added test for mssql ReturnValue

* fixed warnings: unused import: `DataType`
2022-06-08 15:49:12 -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
tyrelr
ed56622526
Improve Sqlite support for sub-queries and CTE's (#1816)
* reproduce incorrect nullability for materialized views

* split ephemeral/index-only table handling from real table handling

* add test for literal null, expect nullability to be identified from table information

* gather interpreter state into a struct, no change in behaviour

* prevent infinite loops that could arise once branching is supported

* track nullability alongside the datatype instead of in a separate lookup

* implement basic comprehension of branching opcodes

* fix datatype calculation of aggregates which are never 'stepped' through

* implement coroutine and return operations, including tracking of 'actual' integer value stored in the register by Integer/InitCoroutine/Yield operations.

* strip unnecessary history field out

* Modify variable test to expect bind-variable outputs to be nullable, rather than unknown

* add partially commented-out union tests, simplify code to satisfy simplest union case

* fix unit test incorrectly expecting primary keys to be implicitly not-null

* add failing test for recursive tables

* add logging of query explain plan

* track explain plan execution history

* broken RowData implementation (doesn't alias)

* Implement OpenPseudo tables as an alias of a register value

* fix comment

* clean up logging code warnings

* use cfg to omit QueryPlanLogger unless sqlite feature is used
2022-06-07 14:24:08 -07:00
Ophir LOJKINE
20d61f4271
query_as: don't stop stream after decoding error (#1887)
* query_as: don't stop stream after decoding error

Fixes https://github.com/launchbadge/sqlx/issues/1884

When a single row cannot be converted to the target type of query_as,
it should not prevent the library user from accessing the other rows

Otherwise, the user cannot access all query results in query_as.

* use union in tests to maximize db compatibility
2022-06-01 19:18:18 -07:00
smonv
4e3ff3644f
trim [ and ] from host string before used to connect by TcpStream (#1818) 2022-05-31 18:03:26 -07:00
Erik Rhodes
c744cb7f60
Avoid panic when streaming packets are empty (#1861)
* changed [] access to .get() to return result instead of panic

* changed error type to protocol err

* fixed issue with comparing ref

* cargo fmt

Co-authored-by: Erik Rhodes <erik@space-nav.com>
2022-05-31 17:58:49 -07:00
Oskar Persson
63291d677f
Fix nullability check for inner joins in postgres (#1863) 2022-05-31 17:58:38 -07:00
Scott Wey
5d91ffc81c
add COLLATE_UTF8MB4_0900_AI_CI (#1856) 2022-05-31 17:58:16 -07:00
Michael Freeborn
1b9c40b3c8
fix serde_json usage in macros (#1842) 2022-05-31 16:58:11 -07:00
Michael Freeborn
a110e75b95
make methods pub (#1843) 2022-05-31 16:57:46 -07:00
Charles Samborski
d5f7e4288d
Fix panics on unknown Postgres type oid when decoding (#1855)
Postgres arrays and records do not fully support custom types. When encountering an unknown OID, they currently default to using `PgTypeInfo::with_oid`. This is invalid as it breaks the invariant that decoding only uses resolved types, leading to panics.

This commit returns an error instead of panicking. This is merely a mitigation: a proper fix would actually add full support for custom Postgres types. Full support involves more work, so it may still be useful to fix this immediate issue.

Related issues:
- https://github.com/launchbadge/sqlx/issues/1672
- https://github.com/launchbadge/sqlx/issues/1797
2022-05-31 16:57:16 -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
Dirkjan Ochtman
fa5c436918
Update crc to 3 (#1831) 2022-05-02 12:44:16 -07:00
Paolo Barbolini
ec15f6b30c
Update uuid crate to v1 (#1821) 2022-04-20 12:48:29 -07:00
Paolo Barbolini
b934f82440
Bump remanining dependencies (#1807)
Co-authored-by: Austin Bonander <austin@launchbadge.com>
2022-04-15 14:34:48 -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
Sebastian Pütz
babd353c2c
Make PgLTree::push infallible and take PgLTreeLabel directly. (#1734)
* Make PgLTree::push infallible and take PgLTreeLabel directly.

Previously the function took strings and parsed them into
PgLTreeLabel internally, now it's possible to directlry push
PgLTreeLabels onto a PgLTree.

* Push PgLTree String conversion to label.

* rebase and fix compile error

Co-authored-by: Austin Bonander <austin@launchbadge.com>
2022-04-14 16:16:00 -07:00
Valentin
c7478dcc66
Update BigDecimal dependency (#1529)
* Update BigDecimal dependency

* rebase onto master

Co-authored-by: Austin Bonander <austin@launchbadge.com>
2022-04-14 16:12:15 -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
17fde443be
Bump ipnetwork to 0.19 (#1426)
* Bump ipnetwork to 0.18

* Bump ipnetwork to 0.19
2022-04-14 15:11:58 -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
08296a28a0
Upgrade rustls to 0.20 (#1505)
* Upgrade rustls to 0.20

* Rustls 0.20.1 is out

* Fix merge conflict mistake

* Bump rustls-pemfile to 0.3

* Resync Cargo.lock

* Bump rustls-pemfile to v1

Co-authored-by: Austin Bonander <austin@launchbadge.com>
2022-04-14 15:11:17 -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
a68957b21f
Make all ConnectOptions clonable (#1612) 2022-04-14 15:07:29 -07:00
05storm26
f328cc15d8
Sqlite chrono::DateTime<FixedOffset> timezone fix (#1618) 2022-04-14 15:06:55 -07:00
Josh Triplett
342d157a50
Update git2 to 0.14 (#1733)
git2-rs recently updated major versions due to libgit2 doing the same.
Bump the version used in sqlx accordingly, to allow users of the new
git2 to use git2::Oid with sqlx.
2022-04-14 15:06:37 -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
Austin Bonander
6c7006c4cc
fix(pool): don't leak connections if drop task doesn't run (#1799)
fixes #1396
2022-04-13 16:39:07 -07:00
Sebastien Guillemot
973f3d154d
Fix newline parsing in pgpass (#1791)
* Fix newline parsing in pgpass

* test loading pgpass from a file

Co-authored-by: Austin Bonander <austin@launchbadge.com>
2022-04-13 14:58:34 -07:00
Austin Bonander
a46e370c94
feat: document and expand query builder (#1790)
elaborates on the API introduced in #1780
2022-04-12 13:22:47 -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
crajcan
a470682572
Add Query builder (#1780)
* Add Query builder

* Make query_builder.rs in sqlx-core

* Add QueryBuilder::new()

* Add QueryBuilder::push()

* Define questions for documentation

* Get new, push, push_bind working with types

* Handle postgres' numbered bind varaibles

* Add a test for QueryBuilder#build

* Move arguments into Option

* Refactor query builder

* Finish testing QueryBuilder#build

* Remove design doc

* Add a test for pushing strings with push_bind

* Integration test green

* Adjust some tests

* Make query builder generic about placeholder segmenent ('$N' or '?')

* Run fmt

* Redesign Arguments#format_placeholder in line with code review

* Use write! to push sql to QueryBuilder

* Add QueryBuilder::reset to allow for QueryBuilder reuse

* Run cargo fmt
2022-04-08 13:36:42 -07:00
david-mcgillicuddy-moixa
6efc39f213
Include affected rows in logging even when query is done (#1754)
* fix logging bug

* slight code cleanup

* change to split rows affected and rows returned

* review comments, and small unreachable bug
2022-04-08 12:40:11 -07:00
Jérémie Drouet
0c95fdd19a
feat(migration): add function to undo migrations (#1675)
Right now, there is only a `run` function to programatically run the
migrations, which is great, but nothing to run the migrations down.

This function adds the possibility to undo the migrations until a
specific version (could say -1 or 0 to remove them all).

With this feature, it's now possible, in the end to end or integration
tests to run the migrations and undo them between each test set and
therefore test the migrations themselves.

This is the kind of feature that some ORM have like sequelize in nodejs
that allow you to undo migrations programatically.

Reference to the doc:
https://sequelize.org/v7/manual/migrations.html#undoing-migrations

Signed-off-by: Jérémie Drouet <jeremie.drouet@gmail.com>
2022-04-07 16:03:00 -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
Andrew Whitehead
acb3da8a34
(mysql) silence warnings for unused fields (#1786)
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
2022-04-05 15:00:32 -07:00
Andrew Whitehead
040eb77d95
add FromStr, Copy, PartialEq, Eq impls for sqlite options (#1784)
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
2022-04-05 12:37:53 -07:00
Austin Bonander
f8581386d2
feat(postgres): make extra_float_digits settable (#1774) 2022-04-01 14:51:29 -07:00
Rafael Ávila de Espíndola
d3093d0b70
Update libsqlite3-sys (#1763) 2022-03-28 15:04:49 -07:00
Austin Bonander
e1817f0a9d
feat: convenient wrapper for Postgres advisory locks (#1641) 2022-03-24 17:38:24 -07:00
Vladimir
9d76f7cd9e
Derive clone for mysql and mssql arguments (#1736) 2022-03-24 11:34:07 -07:00
Ivan Petkov
1af26d8350
sqlx-core: impl Type for Cow<str> on Mssql, MySql, and Sqlite (#1757) 2022-03-23 12:31:43 -07:00
Grachev Mikhail
78dc0ad811
docs(query_as): fix link (#1761) 2022-03-23 12:16:44 -07:00
Grachev Mikhail
3b1801b585
Fix typo in TSTZRANGE (#1741) 2022-03-09 17:54:44 -06:00
Dylan DPC
b40a86ceb7
Update Cargo.toml (#1738) 2022-03-09 11:57:37 -06:00
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