Commit graph

2154 commits

Author SHA1 Message Date
Trangar
ad8ef8d608 Added regexp support in sqlite (#2189)
* CHANGELOG: mention that users should upgrade CLI

* Added regexp support in sqlite

* Added a with_regexp function to sqliteconnectoptions

* Fixed tests

* Undo CHANGELOG.md change

---------

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
Co-authored-by: Victor Koenders <victor.koenders@qrtech.se>
2023-02-21 13:25:25 -08:00
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
Andrés Felipe Quintero Moreano
0534c9da81 fix: ensures recover from fail with PgCopyIn (#2179)
* CHANGELOG: mention that users should upgrade CLI

* fix: ensures recover from fail with PgCopyIn

---------

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
tyrelr
5378dea6af Sqlite describe fixes (#2253)
* add failing test for nested orderby

* log query paths which were abandoned due to invalid state or looping.  Allow instructions to be executed a small number of times to fix nested order by query

* add failing testcase using nested orderby

* fix handling of sequence/offset and rewind

* fix handling when sqlite nests records inside of records

* add test of temporary table handling

* WIP add test failure for temp table access

* fix support for temp tables

* add tests for sqlite datetime functions

* add basic date and time function support

* handle gosub opcode correctly

* add group by test

* fix group by handling

* add additional passing group by test

* add test case for simple limit query

* fix IfPos & If touching wrong branches state, fix IfPos using wrong branch criteria

* add test for large offsets

* add short-circuit for possible query offset loops

* add groupby query that is predicted incorrectly

* fix handling of integer cast failures

* add tests for single-row aggregate results

* fix handling of null-based branching

* add test for coercion of text by sum

* fix calculation of sum value coercion

* add failing test for recursive with query

* add logic for delete operation to fix queries grouping by columns from a recursive query
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
Daniel Tashjian
d00a543613 PgHasArrayType for transparent types fix. (#2086)
Problem: PgHasArrayType was checking the application's postgres feature
Solution: only check the library's postgres feature

Co-authored-by: Daniel Tashjian <daniel@ecomedes.com>
2023-02-21 13:25:25 -08:00
Austin Bonander
6d0d7402c8
fix(actions): quote glob branch filter 2023-02-03 14:18:01 -08:00
Austin Bonander
9d0e596740
Run CI on *-dev branch
I believe this has to be on `main` to actually take effect.
2023-02-03 14:16:53 -08:00
Chris Foster
c828fb5a19
Fixed typo. (#2156) 2023-02-01 16:54:18 -08:00
Austin Bonander
76ae286500
CHANGELOG: mention that users should upgrade CLI 2022-09-20 14:10:52 -07:00
Austin Bonander
ef17af31c2
fix: cannot publish with wildcard dep 2022-09-14 15:47:00 -07: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
Travis Whitehead
09717e1b83
fix: Remove default chrono dep on time for sqlx-cli (#2089)
chrono v0.4.19 includes time 0.1 via default feature flag oldtime.
time 0.1 is deprecated and flagged for: https://rustsec.org/advisories/RUSTSEC-2020-0071
2022-09-12 18:08:39 -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
RustyYato
c5f3513f7d
Fix expansion of sqlx(flatten) (#2023)
Given a generic type like `A<B>` before `sqlx` would produce
`A<B>::from_row(row)` which is invalid syntax.
Now it produces `<A<B> as ::sqlx::FromRow<'a, R>>`.
This also fixes a bug for non-generic types where an inherent method
might have been called instead of the `::sqlx::FromRow::from_row` method
because UFCS wasn't used.
2022-09-02 17:52:05 -07:00
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
cycraig
20af5cd9c3
Use cargo check consistently in prepare (#2071) 2022-08-31 17:02:46 -07:00
cycraig
0823e1139c
Fix prepare race condition in workspaces (#2069)
* Separate offline query metadata per crate

* Update sqlx-cli prepare to use separate query metadata per crate

* Add resolve.root to metadata test fixture

* Simplify root package resolution

* Fix prepare --merged
2022-08-26 17:30:09 -07:00
amos
4c9d23960a
SqliteConnectOptions typo (#2072) 2022-08-26 15:45:32 -07:00
Rakshith Ravi
3f7111f05d
Updated documentation to reflect inet allows for IpAddr (#2053)
Co-authored-by: Austin Bonander <austin.bonander@gmail.com>

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
2022-08-23 15:45:29 -07:00
Adam Cigánek
2d65c5de80
fix: use unlock notify also on sqlite3_exec (#2021) (#2055) 2022-08-22 20:01:48 -07:00
Austin Bonander
5790ffc8d3
fix(docs): close code block in query_builder.rs (#2067)
@danielakhterov and I were playing around with counting lines using regex and noticed that SQLx had an odd number of ` ``` ` and got a little nerd-sniped trying to find it.
2022-08-22 19:54:18 -07:00
Ophir LOJKINE
0e5b9a1bea
fix typo in documentation (#2058) 2022-08-17 17:17:12 -07:00
stoically
26f60d9525
chore: Switch to sha1 crate (#2056) 2022-08-16 17:51:29 -07:00
Austin Bonander
956d8a823a
chore: add Discord link to issue templates 2022-08-15 18:07:50 -07:00
Austin Bonander
e04045cd66
fix: change extension of .github/ISSUE_TEMPLATE/config.yaml to .yml
YAML was a mistake, honestly.
2022-08-15 17:39:42 -07:00
Austin Bonander
ad594ce5cb
Add FAQ and discussions links 2022-08-15 17:36:53 -07:00
Austin Bonander
5245c9e627
Add issue templates (#2052) 2022-08-15 17:35:30 -07:00
zach
326254fb51
Fix typo in FromRow docs (#2040)
Fixes typo: manuel to manual.
2022-08-11 14:24:57 -07:00
Marcus Lee
ca74b0c141
added flag for PIPES_AS_CONCAT connection setting for MySQL to fix #2034 (#2046) 2022-08-11 14:24:32 -07:00
Alexander Jackson
373b121a03
fix: use full macro path (#2028)
When the `#[sqlx::test]` macro is imported using `#[macro_use]` such as
in the following example:

```rust
extern crate sqlx;

mod tests {
    #[test]
    fn something() {}
}
```

then the `#[test]` generated by the macro will refer to itself instead
of the standard Rust `#[test]` macro. This will cause `rustc` to
recursively expand it and produce the following error message:

```
thread 'rustc' has overflowed its stack
fatal runtime error: stack overflow
```

Instead, we can just refer to the standard macro by using its fully
qualified path.

This PR:
* Swaps `#[test]` usages in `#[sqlx::test]` for their hygenic path to
  prevent recursive expansion alongside `#[macro_use]`

Closes #2017.
2022-08-09 21:23:07 -07:00
NSMustache
c4f1816f76
Bump sqlformat to 0.2.0 (#2025)
Fixes #2024
2022-08-08 14:34:56 -07:00