Skip to content

v0.4.0

Choose a tag to compare

@mekadalibrahem mekadalibrahem released this 11 Nov 20:03
· 10 commits to main since this release

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 support

What's new

  • Schema inspection: Schema.getColumns, getColumnListing, hasColumns, getIndexListing
    and hasIndex, on SQLite, PostgreSQL and Android.
  • Index parts: partial indexes (where, whereNull, whereNotNull), asc, desc and
    collate on IndexDefinition, and Blueprint.rawIndex for an index over an expression.
  • Migration lock: SQLite and Android file databases are locked during migrations
    (FileMigrationLock, lock_wait option), 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 and CopyStrategy) and
    dropDatabaseIfExists, on PostgreSQL and SQLite.
  • Blueprint extras: temporary(), table comment(text) and foreignIdFor.
  • Errors: DiwanError.table() names the table a failure concerns.
  • Time values: OffsetTime as a binding and cursor value; a PostgreSQL timezone option.

Changed and fixed

  • index and unique return IndexDefinition instead of void (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: NaN or Infinity read from a numeric column fails with an error that names the
    column and never shows the value.

See the changelog for the full
list.

Links