MemoryDVDatabaseAdapter class

The development database: an in-memory table store that runs the subset of SQL Dartvel itself issues.

It exists so the framework can be run and tested without a database -- a widget test, dartvel dev on a project with none configured, the Studio demo. That only works if it answers the statements the framework writes, and for a long time it did not: Studio's page store, DVDatabaseCacheAdapter and DVDatabaseQueueAdapter all issue CREATE TABLE, scoped DELETE, column-subset SELECT, UPDATE, ORDER BY, LIMIT and COUNT(*), and every one of those threw. Studio's Pages tab rendered the throw where the pages should have been.

What it runs, against rows held in a map:

  • CREATE TABLE [IF NOT EXISTS] t (...) and DROP TABLE [IF EXISTS] t
  • INSERT INTO t (cols) VALUES (...), including an explicit rowid
  • UPDATE t SET col = ... [WHERE ...] and DELETE FROM t [WHERE ...]
  • SELECT [DISTINCT] * | cols | COUNT(*) [AS alias] FROM t [WHERE ...] [ORDER BY col [ASC|DESC], ...] [LIMIT n] [OFFSET n]
  • a WHERE of comparisons -- = != <> < <= > >=, IS NULL and IS NOT NULL -- joined by AND and OR and grouped by parentheses, with AND binding tighter as it does in SQL

Anything else -- a join, a subquery, SQLite's FTS5 MATCH, an ALTER TABLE -- throws an ArgumentError naming the statement. An in-memory adapter that quietly answers a query it did not understand is worse than one that cannot: the wrong rows look exactly like the right ones. Configure SQLite when the answer needs a real database.

Implemented types
Available extensions

Constructors

MemoryDVDatabaseAdapter()

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

classify(DVSchemaChange change) → Future<DVSchemaChangeClass?>

Available on DVDatabaseAdapter, provided by the DVDatabaseAdapterSchemaClassification extension

execute(String sql, [List<Object?>? params]) → Future<int>
override
exportTable(String table) → Map<String, Object?>?
table's rows, their rowids and the next rowid, as data a store that persists this database somewhere else can keep -- or null when there is no such table. importTable reads it back.
importTable(String table, Map<String, Object?> exported) → void
Puts back a table exportTable gave, replacing any of that name.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
query(String sql, [List<Object?>? params]) → Future<List<Map<String, Object?>>>
override
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited