Releases: LHolten/rust-query
Releases · LHolten/rust-query
v0.6.8
v0.6.7
- Fix to allow implicit reference to primary key in sqlite schema.
- Switch to
sqlite3-parserfor lexing the sqlite schema. - Fix to allow unquoted column names in the schema.
- Recreate full table on index change.
This is required when a unique index is defined in a table. - Added cargo-mutants support.
- Fixed bug that would make a unique constraint violation in a migration into a panic.
- Allow changing indices on individual fields without new table.
v0.6.5
v0.6.4
- Added
Transaction::mutableandTransaction::mutable_vec. - Deprecated
Transaction::update_ok. - Fix, only allow
Transaction::lazyon table valued expressions. - Added
Expr::div,Expr::modulo,Expr::concat,Expr::max,Expr::min,
Expr::truncate,Expr::lower,Expr::upper,Expr::sign,Expr::between,
Expr::abs,Expr::zero_blob,Expr::unix_epoch,Expr::char_lenand
Expr::byte_len. - Deprecated
UnixEpoch. - Relaxed trait bound on
Aggregate::maxandAggregate::minto allow table typed
expressions.
Example usage of the new Transaction::mutable API:
// old
txn.update_ok(
&order.customer,
Customer {
balance: Update::add(total_amount),
delivery_cnt: Update::add(1),
..Default::default()
},
);
// new
let mut customer = txn.mutable(&order.customer);
customer.balance += total_amount;
customer.delivery_cnt += 1;
drop(customer);v0.6.3
v0.6.2
- Added diagnostics for differences between rust code and database schema.
The new diagnostics use theannotate-snippetscrate to annotate the rust code.
An example error looks like this:error: Unique constraint mismatch for `#[version(0)]` ╭▸ src/schema/test.rs:146:15 │ LL │ #[unique(baz, field2)] │ ━━━━━━ database does not have this unique constraint LL │ pub struct Foo { ╰╴ ━━━ database has `#[unique(baz, field1)]` - Improved schema reading code to be more flexible.
v0.6.1
v0.6.0
Breaking changes
- Unique constraints are now unnamed.
Using a unique constraint can be done by using the column names in order e.g.
Stock.warehouse(w).item(i)instead ofStock::unique(w, i). - Support for only filtering on some columns with unique constraint syntax e.g.
you can dorows.join(Stock.warehouse(w)), which will join all rows from the Stock
table that match the warehouse. - To create an empty row you now have to use
txn.insert_ok(v0::Empty {})instead or
txn.insert_ok(v0::Empty). Optional::thenis renamed toOptional::then_select.Optional::then_expris renamed toOptional::then.- Migrations now use the
Lazytype instead of a generic typeT: FromExpr.
Added
Transaction::lazyandTransaction::lazy_iterare added, these methods
return rows of typeLazy<'t, Table>, which lazily queries values when they
are accessed.Transaction::lazy_iteraccepts the same kind of argument asRows::join.
So any table, optionally filtered by an index can be queried. For example:
txn.lazy_iter(Post.author(my_user))would iterate over all posts bymy_user.Query::into_iternow returns an iterator that can be moved outside the
Transaction::query. This makes it possible to return the iterator as a function result.Optional::and_thenwas added as a convenient way to combineOptional::and
withOptional::then.- Support for extra indices with the
#[index]attribute. This works exactly
like the#[unique]attribute, but it doesn't have a unique constraint.
Defining an index will also add extra methods to filter on the indexed columns.
Removed
- The generated macros for querying specific columns from tables were removed.
This also means the removal ofMacroRoot, which was only used by these macros.
Lazyshould be used instead.
v0.5.2
- Add option to configure
foreign_keys. - Simplify generated query without joins.
- Preserve column definition order when creating unique constraint.
This lets the user choose the ordering, allowing the unique constraint to be used as a covering index. - Add lock for mutable transactions to fix transaction timeout under load.
The lock is dropped before committing to allow the next mutable transaction to start. - Optimize
LEFT JOINtoJOINwhen the joined row is guaranteed to exist.
This allows sqlite to reorder more joins for faster execution plans.