* 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
* 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>
* 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!
* 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
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,"
* 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.
@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.
* 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>
* 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>
* 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
* 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
* 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
* 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>
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.
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.
* pool: fix panic when using callbacks
add regression test
* pool: fix panic when using callbacks
add regression test
added missing typedef `MssqlPoolOptions`
* 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
* 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
* 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
* 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
* 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>
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
* 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`
* 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>
* 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
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.
* 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
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>
* 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
* 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
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.
* 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
* 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
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
* 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
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)