Repository navigation
v0.4.0
Diwan Database 0.4.0
Schema, migrations and test support: read the schema back, shape indexes, keep two processes from
migrating at once, give each test its own database, and fix the date, time and transaction bugs apps
reported. One binary change: index and unique now return IndexDefinition, so code compiled
against 0.3.x must be recompiled; the source compiles unchanged.
Install
implementation("org.aristonis:diwan-database:0.4.0")
implementation("org.aristonis:diwan-database-sqlite:0.4.0") // or -pgsql
implementation("org.aristonis:diwan-database-eloquent:0.4.0") // models, optional
implementation("org.aristonis:diwan-database-android:0.4.0") // Android driver, optional
testImplementation("org.aristonis:diwan-database-testing:0.4.0") // test supportWhat's new
- Schema inspection:
Schema.getColumns,getColumnListing,hasColumns,getIndexListing
andhasIndex, on SQLite, PostgreSQL and Android. - Index parts: partial indexes (
where,whereNull,whereNotNull),asc,descand
collateonIndexDefinition, andBlueprint.rawIndexfor an index over an expression. - Migration lock: SQLite and Android file databases are locked during migrations
(FileMigrationLock,lock_waitoption), so two processes do not migrate one file at once. - Test database modes:
RefreshDatabase.rollback(...).restartingIdentities()gives the same
PostgreSQL ids on every run;RefreshDatabase.template(...)gives each test its own copy of a
migrated template, so tests may commit and run in parallel (PostgreSQL and SQLite files). - Create and drop databases:
Schema.createDatabase(with a template andCopyStrategy) and
dropDatabaseIfExists, on PostgreSQL and SQLite. - Blueprint extras:
temporary(), tablecomment(text)andforeignIdFor. - Errors:
DiwanError.table()names the table a failure concerns. - Time values:
OffsetTimeas a binding and cursor value; a PostgreSQLtimezoneoption.
Changed and fixed
indexanduniquereturnIndexDefinitioninstead ofvoid(recompile against 0.4.0).- PostgreSQL: work in a transaction aborted by a failed statement is refused with a clear error
instead of server error 25P02. - Android: a commit that fails on a deferred foreign key now rolls back.
- PostgreSQL:
NaNorInfinityread from anumericcolumn fails with an error that names the
column and never shows the value.
See the changelog for the full
list.
Links
- Documentation: https://aristonis.org/open-source/diwan-database/docs/main/home
- Full changelog: CHANGELOG.md
- Report a security problem privately: SECURITY.md