* feat: create `sqlx.toml` format
* feat: add support for ignored_chars config to sqlx_core::migrate
* chore: test ignored_chars with `U+FEFF` (ZWNBSP/BOM)
https://en.wikipedia.org/wiki/Byte_order_mark
* refactor: make `Config` always compiled
simplifies usage while still making parsing optional for less generated code
* refactor: add origin information to `Column`
* feat(macros): implement `type_override` and `column_override` from `sqlx.toml`
* refactor(sqlx.toml): make all keys kebab-case, create `macros.preferred-crates`
* feat: make macros aware of `macros.preferred-crates`
* feat: make `sqlx-cli` aware of `database-url-var`
* feat: teach macros about `migrate.table-name`, `migrations-dir`
* feat: teach macros about `migrate.ignored-chars`
* chore: delete unused source file `sqlx-cli/src/migration.rs`
* feat: teach `sqlx-cli` about `migrate.defaults`
* feat: teach `sqlx-cli` about `migrate.migrations-dir`
* feat: teach `sqlx-cli` about `migrate.table-name`
* feat: introduce `migrate.create-schemas`
* WIP feat: create multi-tenant database example
* fix(postgres): don't fetch `ColumnOrigin` for transparently-prepared statements
* feat: progress on axum-multi-tenant example
* feat(config): better errors for mislabeled fields
* WIP feat: filling out axum-multi-tenant example
* feat: multi-tenant example
No longer Axum-based because filling out the request routes would have distracted from the purpose of the example.
* chore(ci): test multi-tenant example
* fixup after merge
* fix(ci): enable `sqlx-toml` in CLI build for examples
* fix: CI, README for `multi-tenant`
* fix: clippy warnings
* fix: multi-tenant README
* fix: sequential versioning inference for migrations
* fix: migration versioning with explicit overrides
* fix: only warn on ambiguous crates if the invocation relies on it
* fix: remove unused imports
* fix: doctest
* fix: `sqlx mig add` behavior and tests
* fix: restore original type-checking order
* fix: deprecation warning in `tests/postgres/macros.rs`
* feat: create postgres/multi-database example
* fix: examples/postgres/multi-database
* fix: cargo fmt
* chore: add tests for config `migrate.defaults`
* fix: sqlx-cli/tests/add.rs
* feat(cli): add `--config` override to all relevant commands
* chore: run `sqlx mig add` test with `RUST_BACKTRACE=1`
* fix: properly canonicalize config path for `sqlx mig add` test
* fix: get `sqlx mig add` test passing
* fix(cli): test `migrate.ignored-chars`, fix bugs
* feat: create `macros.preferred-crates` example
* fix(examples): use workspace `sqlx`
* fix: examples
* fix(sqlite): unexpected feature flags in `type_checking.rs`
* fix: run `cargo fmt`
* fix: more example fixes
* fix(ci): preferred-crates setup
* fix(examples): enable default-features for workspace `sqlx`
* fix(examples): issues in `preferred-crates`
* chore: adjust error message for missing param type in `query!()`
* doc: mention new `sqlx.toml` configuration
* chore: add `CHANGELOG` entry
Normally I generate these when cutting the release, but I wanted to take time to editorialize this one.
* doc: fix new example titles
* refactor: make `sqlx-toml` feature non-default, improve errors
* refactor: eliminate panics in `Config` read path
* chore: remove unused `axum` dependency from new examples
* fix(config): restore fallback to default config for macros
* chore(config): remove use of `once_cell` (to match `main`)
* feat: Implement `get_transaction_depth` for drivers
* test: Verify `get_transaction_depth()` on postgres
* Refactor: `TransactionManager` delegation without BC
SQLite implementation is currently WIP
* Fix: Avoid breaking changes on `AnyConnectionBackend`
* Refactor: Remove verbose `SqliteConnection` typing
* Feat: Implementation for SQLite
I have included `AtomicUsize` in `WorkerSharedState`. Ideally, it is not desirable to execute `load` and `fetch_add` in two separate steps, but we decided to allow it here since there is only one thread writing. To prevent writing from other threads, the field itself was made private, and a getter method was provided with `pub(crate)`.
* Refactor: Same approach for `cached_statements_size`
ref: a66787d36d62876b55475ef2326d17bade817aed
* Fix: Add missing `is_in_transaction` for backend
* Doc: Remove verbose "synchronously" word
* Fix: Remove useless `mut` qualifier
* feat: add Connection::begin_with
This patch completes the plumbing of an optional statement from these methods to
`TransactionManager::begin` without any validation of the provided statement.
There is a new `Error::InvalidSavePoint` which is triggered by any attempt to
call `Connection::begin_with` when we are already inside of a transaction.
* feat: add Pool::begin_with and Pool::try_begin_with
* feat: add Error::BeginFailed and validate that custom "begin" statements are successful
* chore: add tests of Error::BeginFailed
* chore: add tests of Error::InvalidSavePointStatement
* chore: test begin_with works for all SQLite "BEGIN" statements
* chore: improve comment on Connection::begin_with
* feat: add default impl of `Connection::begin_with`
This makes the new method a non-breaking change.
* refactor: combine if statement + unwrap_or_else into one match
* feat: use in-memory SQLite DB to avoid conflicts across tests run in parallel
* feedback: remove public wrapper for sqlite3_txn_state
Move the wrapper directly into the test that uses it instead.
* fix: cache Status on MySqlConnection
* fix: compilation errors
* fix: format
* fix: postgres test
* refactor: delete `Connection::get_transaction_depth`
* fix: tests
---------
Co-authored-by: mpyw <ryosuke_i_628@yahoo.co.jp>
Co-authored-by: Duncan Fairbanks <duncanfairbanks6@gmail.com>
* feat: implement serialze no copy on lockedsqlitehandle
* feat: implement serialize on sqliteconnection
* feat: implement deserialize on sqliteconnection and add sqlitebuf wrapper type
* refactor: misc sqlite type and deserialize refactoring
* chore: misc clippy refactoring
* fix: misc refactoring and fixes
- pass non-owned byte slice to deserialize
- `SqliteBufError` and better error handling
- more impl for `SqliteOnwedBuf` so it can be used as a slice
- default serialize for `SqliteConnection`
* refactor: move serialize and deserialize on worker thread
This implements `Command::Serialize` and `Command::Deserialize` and moves the
serialize and deserialize logic to the worker thread.
`Serialize` will need some more iterations as it's not clear whether it would
need to wait for other write transactions before running.
* refactor: misc refactoring and changes
- Merged deserialize module with serialize module
- Moved `SqliteOwnedBuf` into serialize module
- Fixed rustdocs
* chore: API tweaks, better docs, tests
* fix: unused import
* fix: export `SqliteOwnedBuf`, docs and safety tweaks
---------
Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
Both actix_web::web::Data and sqlx::PgPool internally wrap an Arc. Thus,
using Data<PgPool> as an extractor in an actix-web route handler results
in two Arcs wrapping the data of interest, which isn't ideal.
Actix-web 4.9.0 introduced a new web::ThinData extractor for cases like
this, where the data is already wrapped in an `Arc` (or is otherwise
similarly cheap and sensible to simply clone), which doesn't wrap the
inner value in a (second) Arc.
Since the new extractor is better suited to the task, suggest it in
place of web::Data when giving an example on how to share a pool.
When sqlx-core/src/from_row.rs was updated to implement FromRow for tuples of up to 16 values, a comment was left stating that it was implemented up to tuples of 9 values.
The `try_from` and `json` sections are "Field attributes" so they should probably be part of the corresponding section instead of subsections of "Manual implementation". `flatten` should be H4 instead of H3, since "Field attributes" is H3 and all other field attribute sections are H4 too.
query_as.rs: 230 mismatched bracket.
query_as.rs: 230 move TIMESTAMP to TIMESTAMPTZ to match type time::OffsetDateTime.
query_as.rs: 241, 251, 260 move i64 to i32 to match postgres type `INT4`.
* Add a "sqlite-unbundled" feature that dynamically links to system libsqlite3.so library
* update README abouot the newly-added `sqlite-unbundled` feature
* Update README.md to make it clear with bulleted list
Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
* more cfg feature updates
Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
* update documentation in sqlx-sqlx/src/lib.rs too
and also mention possible build time increasement.
* cargo fmt
* Add "sqlite-unbundled" feature to sqlx-cli
* Add sqlite-unbundled to gituhb actions tests
* cfg(feature = "sqlite") => cfg(any(feature = "sqlite", feature = "sqlite-unbundled"))
* fix
* CI: make sqlite-unbundled tests workaround required-features
by duplicating the relevant test section
* use an internal "_sqlite" feature to do the conditional compilation
---------
Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
* fix(postgres): make `PgStream::recv_unchecked()` cancel-safe
* fix(postgres): make `PgListener` close the connection on-error
* fix: incorrect math in `BufferedSocket::read_buffered()`
* add information and example on using json in query macros
* run cargo format
* add missing bracket to docs of json
* wrap docs in hidden async function
* change no_run to ignore