A session used to run statements against a database.
In drift, database connections (or even database pools) can implement DriftSession to execute queries. Additionally, DriftSession instances are also used to represent transactions starte on a connection. While such an inner session is active, the outer one is typically blocked (unless the database supports multiple concurrent transactions, which might be the case for e.g. a PostgreSQL pool).
All DriftSession implementations provide execute and executeBatch methods. Optional functionality is exposed through nullable getters:
- Top-level connections typically implement
schemaVersionto support drift's schema management. - If the driver supports opening transactions, transactionParent should
return an implementation for that. Drivers don't need to support this
though, drift can also run
BEGINandCOMMITstatements manually. - In a transaction, transaction should return an instance allowing transactions to be committed or rolled back.
- Available extensions
Properties
-
closed
→ Future<
void> -
A future that completes as isClosed becomes
true.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- isClosed → bool
-
Whether this session has been closed, meaning that no further operations
can run on it.
no setter
- locks → DriftSessionWithInternalLocks?
-
If this session can be locked, a DriftSessionWithInternalLocks instance
through which an exclusive lock on the session can be obtained.
no setter
- persistentSchemaVersion → PersistentSchemaVersion?
-
If this session has schema management method, return a
PersistentSchemaVersion instance for it.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- tag → Object?
-
An arbitrary and user-defined tag that may be attached to sessions.
final
- transaction → DriftTransactionSession?
-
If this session represents a a transaction, returns a
DriftTransactionSession that can be used to commit or rollback the
transaction.
no setter
- transactionParent → DriftTransactionParent?
-
If this session can open transactions, a DriftTransactionParent through
which transactions can be started.
no setter
Methods
-
close(
) → Future< void> - Closes this drift session, releasing associated resources.
-
execute(
StatementInfo statement) → Future< QueryResult> - Runs the given SQL StatementInfo, returning results.
-
executeBatch(
StatementBatch batch) → Future< List< QueryResult> > - A variant of execute that can prepare a statement once and then run it multiple times with different parameter sets.
-
interceptWith(
QueryInterceptor interceptor, {bool sticky = true}) → DriftSession -
Available on DriftSession, provided by the ApplyInterceptor extension
Returns a DriftSession that will usethisexecutor internally, but with calls intercepted by the giveninterceptor. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited