angel3_orm_sqlite 10.1.0
angel3_orm_sqlite: ^10.1.0 copied to clipboard
SQLite support for Angel3 ORM, on sqlite_async or sqlite3. Includes functionality for querying and transactions.
Change Log #
10.1.0 #
New in 10.1.0 #
- Errors:
SqliteExecutorandSqliteAsyncExecutorclassify aSqliteExceptionby its extended result code (classifyError, ofangel3_orm10.3.0, which this version requires):2067,1555and2579(a rowid) a duplicate key,1299aNOT NULLviolation,787a foreign key one (withPRAGMA foreign_keys = ON), and275(CHECK),3091(a value of the wrong type in aSTRICTtable) and20(a type mismatch) an invalid value, as is18(a text or blob too long) of a statement that writes, but not of a query that only reads, whose result is too long. The column of a duplicate key of one column, aNOT NULLviolation and a value of the wrong type in aSTRICTtable is that of the message, read by the table of the query as SQL reads it (aux.usersisusersof the schemaaux,"my.t"a table of that name), in any case of ASCII letters, so that the names of tables and columns may have dots and commas. A message of another table, as of a trigger, names no column; one of a query given the table''is read up to its first dot. A key of several columns, or the hiddenrowid, names none. The constraint of a unique index on an expression is the name of the index, and that of a failedCHECKits name, if the table declares one by that name, which the executor reads after the error from the schema of the table, as SQLite finds it, rather than its expression.SqliteAsyncExecutorreads it on a connection that reads, and, for aTEMPtable or one of an attached database, on the one that writes, waiting for it half a second at most.classifySqliteErroris the function they use
10.0.1 #
Fixes in 10.0.1 #
- Docs: The README is rewritten in plain English, with a table of contents, a section on choosing an executor, and the transaction rules split into subsections
10.0.0 #
New in 10.0.0 #
- Executors:
SqliteAsyncExecutorruns the queries ofangel3_ormon a SQLite database of thesqlite_asyncpackage, in background isolates, so that they do not block the isolate that gives them, as on a server: it writes on one connection, and reads outside a transaction on others, in WAL mode, without waiting for a transaction.SqliteExecutorruns them on a database of thesqlite3package, synchronously, on one connection, as for tests and command-line programs. Both store values the same way, on SQLite 3.35 or later. Requiresangel3_orm10.2.0 - Transactions: A transaction holds the write lock of the database, beginning with
BEGIN IMMEDIATE: a query given outside it waits for it to end, but for a read withSqliteAsyncExecutoron a pool, which runs at once and sees the rows as they were before it. The executor of its callback runs its queries in it from any zone. A transaction in a transaction is a savepoint of it, which is rolled back alone; savepoints run one at a time, so that concurrent updates and deletes in a transaction do not interleave, and transactions of separate requests one after the other. A transaction that SQLite rolled back after an error runs no more statements and throws aStateError, as does, withSqliteExecutor, one whose savepoint could not be rolled back, which is rolled back whole. A query given by code that runs after its savepoint ended, as of a timer, runs in the transaction of the savepoint. A statement given to a transaction while it commits or rolls back fails with aStateError, as does a statement, a transaction orclose()given by the code of its callback to another executor then, as does one given to the executor of an ended transaction, which returns a failedFuturerather than throwing. Onceclose()is called, a query or transaction given outside a transaction fails at once with aStateError, and the database closes when the transactions, and the queries given before it, have ended - Values: A
DateTimeis stored as UTC text that sorts in time order, ofSqliteDialect.formatDateTime, aboolas0or1, aUint8Listas a BLOB, and aMapor aListas JSON text. A placeholder with no value throws anArgumentError - Reads: With
SqliteAsyncExecutor, aSELECToutside a transaction, and a union of them, runs on a connection that reads - Inserts: An insert returns its row by the id of the row SQLite inserted, which may be a text id given by a default, and none if it inserted none. The insert and the select of its row are atomic: if the select fails, the row is not inserted, in a transaction too, and, with
SqliteExecutor, in one begun on thesqlite3database itself