orbiter_postgres 0.1.10
orbiter_postgres: ^0.1.10 copied to clipboard
PostgreSQL kit for orbiter: the pieces for using it together with slingshot_postgres (a per-request row-level-security transaction middleware and a prefix tsquery builder).
Changelog #
0.1.10 #
SqlBatchandrunBatchonSqlFirstQueries: the batch of independent@namequeries with typed results. EachSqlBatch.addreturns aSqlBatchResult<T>whoserowsis aList<T>once the batch ran, with no.cast<T>(). Same single round-trip throughPostgresBatchExecutor, same one-by-one fallback, every result set released. Results are filled only when the whole batch succeeded;rowsbefore that, a secondrunBatchandaddafter running throwStateError.queryBatch: each list is now built by its ownSqlBatchQuery, so a query created with an explicit type argument (SqlBatchQuery<Grant>(...)) comes back as aList<Grant>andas List<Grant>works. Queries whose type is inferred inside the list literal still giveList<Object?>, as before;.cast<T>()keeps working. A typed list rejectsaddof another type.
0.1.9 #
queryBatchonSqlFirstQueries: several independent@namequeries (SqlBatchQuery, each with its own mapper), one list of mapped rows per query. When the executor implementsPostgresBatchExecutor(asslingshot_postgres's own does) they go to the server in one round-trip, through the statement cache when it is on; otherwise they run one after the other, with the same results. Requiresslingshot_postgres^0.1.14.
0.1.8 #
-
inferParam(and soquery,queryFirstandscalarwith@name) binds aListorSetas a one-dimensional array:int8[],float8[],bool[]ortext[]by element type, nulls allowed, forWHERE id = ANY(@ids). An empty or all-null list goes untyped and takes its type from context. Mixed element types still throwArgumentError, and so do maps. Requiresslingshot_postgres^0.1.12, which has the array parameters. -
README: the SQL-first "Cost" section now reports the measured cost of the cached rewrite (about 80 ns per call) instead of "Not measured yet". Documentation only.
0.1.7 #
- Migrations and seeds:
MigratorandSeederapply numbered.sqlfiles (SqlScript, from a directory or built in memory) once each, in numeric version order, each file sent whole in one transaction with its bookkeeping row. Applied files are checked by CRC-32 before anything runs, an advisory lock serialises concurrent runs, and-- orbiter:no-transactionopts a file out of the transaction. Failures throwMigrationException. - SQL-first queries:
query,queryFirstandscalaras an extension onPostgresQueryExecutorContract, with@nameplaceholders rewritten to$Nonce per SQL text (cached) and parameter types inferred from Dart values (inferParam). The result set is always released.namedStmtreturns the positional record forPostgresRepository.NamedSqlexposes the rewrite. No change to existing API.
0.1.6 #
Documentation only: README rewritten, the CRUD server example renamed to example/main.dart, dartdoc on the
exception constructors. No API change.
0.1.5 #
First release on pub.dev. Depends on orbiter ^0.1.3 and slingshot_postgres ^0.1.5 from pub.dev instead
of by git. No API change.
0.1.4 #
Renamed from dart_backend_framework_postgres to orbiter_postgres; the repository moved with it. No API change: only the package
name, the library import (package:orbiter_postgres/orbiter_postgres.dart) and the dependency key change. Depends on orbiter and
slingshot_postgres, the renamed framework and connector.
0.1.3 #
Consumed by git reference to the tag v0.1.3. Depends on dart_backend_framework 0.1.0 and
dart_db_connector_postgres 0.1.3, as before.
Added #
withTenantTransaction(pool, tenantId, body): the RLS transaction opened by a repository or use case instead of the request pipeline. Same sequence and exceptions asrlsTransaction: rollback and rethrow when the function throws, rollback whensetRollbackOnly()was called, rollback andRlsCommitExceptionwhenCOMMITfails; aPoolExhaustedExceptionpropagates. Returns the value of the function.localSettingsonwithTenantTransaction: other transaction-local settings (such asapp.correlation_id) applied in the same first statement as the tenant, every name and value bound as a parameter. Invalid names throwArgumentErrorbefore the pool is touched.TenantRequiredException, thrown before the pool is touched when the tenant isnullor empty. It is outside the sealedRlsException, so existing exhaustiveswitchstatements keep compiling.withTenantTransactionOn, the same function over anyUnitOfWorkfactory, for tests without a database.
Changed #
- Nothing changes for
rlsTransaction: the statement that applies the tenant is the same.
Documentation #
- README: a section on
withTenantTransaction; and, underrlsTransaction, "Errors and configuration", covering the sealedRlsException, when each exception is thrown and what the client gets, theTenantResolverandCommitPredicatetypes,settingNameandrlsTransactionOn.
Tests #
- Repository-mode tests without a database, against PostgreSQL (tenant isolation, rollback, local settings that do not outlive the transaction, exhausted pool) and in the stress suite.
0.1.2 #
Consumed by git reference to the tag v0.1.2. Depends on dart_backend_framework 0.1.0 and
dart_db_connector_postgres 0.1.3.
Added #
prefixTsQuery(input): a prefixtsquery('jo':* & 'sil':*) from free text, forto_tsquery(config, $1)withParam.text. Only letters, combining marks and digits survive; operators, quotes and backslashes are separators. Returnsnullwhen there is no word.
Changed #
- The package is described as the PostgreSQL kit for applications that use the framework with the connector.
- The connector dependency moves to 0.1.3 (from 0.1.1), so this kit and the connector at 0.1.3 can be used together.
Through the connector,
tsvector,tsqueryandregconfigvalues now read asString; see its CHANGELOG.
Tests #
- The integration tests no longer point to a directory outside the package; their header and the README "Tests" section say which PostgreSQL they expect.
- Operator-injection tests for
prefixTsQuery, without a database and against PostgreSQL. - A public-surface test over the package barrel.
0.1.1 #
Consumed by git reference to the tag v0.1.1. Depends on dart_backend_framework 0.1.0 and
dart_db_connector_postgres 0.1.1.
- No code change. The connector dependency moves to 0.1.1, so this extension and the connector at 0.1.1 can be
used together; on 0.1.0 they conflicted in
pub get.
0.1.0 #
First public release, consumed by git reference to the tag v0.1.0. Depends on dart_backend_framework
0.1.0 and dart_db_connector_postgres 0.1.0.
rlsTransaction/rlsTransactionOn: one transaction per request with the tenant set by a parameterisedset_configas its first statement; commit before the response is written (buffered body) or after the last byte (stream); rollback on exception, on a status of 400 or above (shouldCommit, defaultcommitOnSuccess) or onsetRollbackOnly();onUnresolvedwithout borrowing a connection when there is no tenant;503withRetry-Afterwhen the pool is exhausted.RlsException,RlsContextException,RlsCommitException.- Example CRUD server in
example/.