Repository navigation
Diwan Database 0.3.0
Diwan Database 0.3.0
What apps built on 0.2.0 asked for: money that stays exact, searches that take user input as typed,
errors an app can act on, lock waits that end, and test support. Code written for 0.2.0 compiles and
runs unchanged.
Install
implementation("org.aristonis:diwan-database:0.3.0")
implementation("org.aristonis:diwan-database-sqlite:0.3.0") // or -pgsql
implementation("org.aristonis:diwan-database-eloquent:0.3.0") // models, optional
implementation("org.aristonis:diwan-database-android:0.3.0") // Android driver, optional
testImplementation("org.aristonis:diwan-database-testing:0.3.0") // test support, newWhat's new
- Test support (new artifact):
RefreshDatabase.rollback(...)and.truncate(...)migrate once
per run and reset between tests by rollback or by truncate;DatabaseAssertionsgives
assertHas,assertMissing,assertCount,assertEmpty,assertModelExists,
assertSoftDeletedand more, never printing hidden columns. - Strict decimals:
Casts.decimal(precision, scale)refuses a value that does not fit instead
of rounding, with an optionalRoundingMode; on SQLite it also refuses more than 15 significant
digits.Casts.decimalText(p, s)keeps longer values exact in a text column.sumDecimal(column, scale)sums money in SQL and returns it at its scale. - Search user input safely:
whereContains,whereStartsWithandwhereEndsWithescape%
and_, with a case-sensitive flag. - Errors you can act on:
DriverExceptionnames the constraint and columns where the database
says them, and carries a stableDWN-error code; check and not-null violations have their own
kinds. - Lock wait limits:
TransactionOptions.lockWait(Duration)per transaction,
lock(strength, Duration)per statement on PostgreSQL, and alock_waitconnection option; a
wait that runs out is a concurrency failure thatattemptsretries. - Schema and data reset:
getTables,getTableListing,getViews,dropAllTables,
dropAllViews,Migrator.fresh(), andtruncate(List<String>[, cascade])that empties many
tables in one call (cascade emulated on SQLite).
Changed and fixed
- SQLite
truncateno longer fails on a database with no autoincrement table. Connection.transaction(callback, attempts)is now a default method; callers are unaffected.
Links
- Documentation: https://aristonis.org/open-source/diwan-database/docs/main/home
- Full changelog: CHANGELOG.md
- Report a security problem privately: SECURITY.md