v1.14.0
-
New
DBSQLiteAdapter: an embedded SQLite DB adapter, backed by the
sqlite3package.import 'package:bones_api/bones_api_db_sqlite.dart'; var adapter = DBSQLiteAdapter('/var/lib/myapp/db.sqlite', generateTables: true); // Or an in-memory database: var memoryAdapter = DBSQLiteAdapter(':memory:', generateTables: true);
-
Registered as
sqlite,sqlite3,sql.sqliteandsql.sqlite3, so a
config blockdb: { sqlite: {...} }resolves it. -
fromConfigacceptspath/file/database/dbfor the database file,
andmemory: true(or the path:memory:) for an in-memory database, plus
the usualgenerateTables/checkTables/populate/log.sqlkeys.
Irrelevant keys (host,port,username,password) are accepted and
ignored, so a config can be pointed at SQLite without being rewritten. -
No server and no native library to install: the
sqlite3package
bundles SQLite (3.53.4) through Dart's build hooks. -
Runs the same entity test-suite as the PostgreSQL and MySQL adapters, and
needs noDockercontainer to do it. NewAPITestConfigSQLite, exported by
package:bones_api/bones_api_test_sqlite.dart. -
Notes on the SQLite dialect:
- An auto-assigning ID is declared
INTEGER PRIMARY KEY AUTOINCREMENT:
SQLite has noSERIAL/AUTO_INCREMENT, only a column declared exactly
INTEGER PRIMARY KEYaliases therowid, and withoutAUTOINCREMENT
SQLite reuses the ID of a deleted row. ENUMis emulated with aVARCHAR CHECK (col IN (...))constraint.- Since
sqlite3is a synchronous driver, and SQLite allows a single
writer, the adapter uses one native handle shared by every pooled
connection: a second handle blocking on a lock would stall the isolate
holding it, and offers nothing to gain when there is no I/O to overlap.
Nested transactions useSAVEPOINT.
- An auto-assigning ID is declared
-
-
New
SQLDialect.returningAcceptsTableWildcard(defaulttrue, so the
PostgreSQL/MySQL/memory dialects are unchanged). SQLite rejects the
table-qualified wildcard thatDELETE ... RETURNINGemits
("RETURNING may not use TABLE.* wildcards") and needs a bare
RETURNING *. -
Fixed
DBObjectDirectoryAdapterlosing objects written just before a read:
_saveObjectwasasyncand itsFuturewas dropped bydoInsert/
doUpdate, while every reader in the adapter inspects the filesystem
synchronously. Astorecould therefore return before its object was on
disk, andselectAllwould silently omit it (a not-yet-written file reads
back asnulland was discarded). The write is now synchronous. -
Breaking: the minimum Dart SDK is now 3.10.0 (was 3.7.0), required by
sqlite3and its build hooks. -
Dependencies:
- Added
sqlite3: ^3.5.1
- Added