Skip to main content

orbiter_postgres 0.1.10 copy "orbiter_postgres: ^0.1.10" to clipboard
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 #

  • SqlBatch and runBatch on SqlFirstQueries: the batch of independent @name queries with typed results. Each SqlBatch.add returns a SqlBatchResult<T> whose rows is a List<T> once the batch ran, with no .cast<T>(). Same single round-trip through PostgresBatchExecutor, same one-by-one fallback, every result set released. Results are filled only when the whole batch succeeded; rows before that, a second runBatch and add after running throw StateError.
  • queryBatch: each list is now built by its own SqlBatchQuery, so a query created with an explicit type argument (SqlBatchQuery<Grant>(...)) comes back as a List<Grant> and as List<Grant> works. Queries whose type is inferred inside the list literal still give List<Object?>, as before; .cast<T>() keeps working. A typed list rejects add of another type.

0.1.9 #

  • queryBatch on SqlFirstQueries: several independent @name queries (SqlBatchQuery, each with its own mapper), one list of mapped rows per query. When the executor implements PostgresBatchExecutor (as slingshot_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. Requires slingshot_postgres ^0.1.14.

0.1.8 #

  • inferParam (and so query, queryFirst and scalar with @name) binds a List or Set as a one-dimensional array: int8[], float8[], bool[] or text[] by element type, nulls allowed, for WHERE id = ANY(@ids). An empty or all-null list goes untyped and takes its type from context. Mixed element types still throw ArgumentError, and so do maps. Requires slingshot_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: Migrator and Seeder apply numbered .sql files (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-transaction opts a file out of the transaction. Failures throw MigrationException.
  • SQL-first queries: query, queryFirst and scalar as an extension on PostgresQueryExecutorContract, with @name placeholders rewritten to $N once per SQL text (cached) and parameter types inferred from Dart values (inferParam). The result set is always released. namedStmt returns the positional record for PostgresRepository. NamedSql exposes 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 as rlsTransaction: rollback and rethrow when the function throws, rollback when setRollbackOnly() was called, rollback and RlsCommitException when COMMIT fails; a PoolExhaustedException propagates. Returns the value of the function.
  • localSettings on withTenantTransaction: other transaction-local settings (such as app.correlation_id) applied in the same first statement as the tenant, every name and value bound as a parameter. Invalid names throw ArgumentError before the pool is touched.
  • TenantRequiredException, thrown before the pool is touched when the tenant is null or empty. It is outside the sealed RlsException, so existing exhaustive switch statements keep compiling.
  • withTenantTransactionOn, the same function over any UnitOfWork factory, 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, under rlsTransaction, "Errors and configuration", covering the sealed RlsException, when each exception is thrown and what the client gets, the TenantResolver and CommitPredicate types, settingName and rlsTransactionOn.

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 prefix tsquery ('jo':* & 'sil':*) from free text, for to_tsquery(config, $1) with Param.text. Only letters, combining marks and digits survive; operators, quotes and backslashes are separators. Returns null when 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, tsquery and regconfig values now read as String; 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 parameterised set_config as 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, default commitOnSuccess) or on setRollbackOnly(); onUnresolved without borrowing a connection when there is no tenant; 503 with Retry-After when the pool is exhausted.
  • RlsException, RlsContextException, RlsCommitException.
  • Example CRUD server in example/.
1
likes
160
points
760
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

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).

Repository (GitHub)
View/report issues

Topics

#postgres #rls #backend

License

MIT (license)

Dependencies

meta, orbiter, slingshot_postgres

More

Packages that depend on orbiter_postgres