PostgresDriverAdapter class

PostgreSQL implementation of the routed ORM driver adapter.

Implemented types

Constructors

PostgresDriverAdapter.custom({required DatabaseConfig config, ConnectionFactory? connections})
PostgresDriverAdapter.fromUrl(String url, {ConnectionFactory? connections})
factory
PostgresDriverAdapter.insecureLocal({String database = 'postgres', String username = 'postgres', String? password, ConnectionFactory? connections})
factory

Properties

codecs → ValueCodecRegistry
Registry of codecs used when marshalling values.
no setter
hashCode int
The hash code for this object.
no setterinherited
metadata → DriverMetadata
Advertises the capabilities supported by this adapter.
no setter
planCompiler → PlanCompiler
Compiler used by this adapter to translate ORM plans.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

applySchemaPlan(SchemaPlan plan) Future<void>
Executes the given plan, typically inside a transaction when supported.
override
beginTransaction() Future<void>
Begins a new database transaction.
close() Future<void>
Closes the underlying connections/resources.
commitTransaction() Future<void>
Commits the active database transaction.
createDatabase(String name, {Map<String, Object?>? options}) Future<bool>
Creates a new database with the given name.
override
createSchema(String name) Future<bool>
Creates a new schema/namespace within the current database.
override
createSchemaState({required OrmConnection connection, required String ledgerTable}) → SchemaState?
Returns a SchemaState capable of dumping/loading the schema for the provided ledgerTable, or null if the driver cannot produce dumps.
describeMutation(MutationPlan plan) → StatementPreview
Provides a statement preview for a mutation plan without executing it.
describeQuery(QueryPlan plan) → StatementPreview
Provides a statement preview for a read plan without executing it.
describeSchemaPlan(SchemaPlan plan) SchemaPreview
Returns a preview of the SQL statements that would run for plan.
override
disableForeignKeyConstraints() Future<bool>
Disables foreign key constraint checking. Returns true if successful.
override
dropAllTables({String? schema}) Future<void>
Drops all tables from the database. Automatically handles foreign key constraints.
override
dropDatabase(String name) Future<bool>
Drops a database with the given name. Throws if database doesn't exist.
override
dropDatabaseIfExists(String name) Future<bool>
Drops a database if it exists. Returns true if dropped, false if didn't exist.
override
dropSchemaIfExists(String name) Future<bool>
Drops a schema/namespace if it exists.
override
enableForeignKeyConstraints() Future<bool>
Enables foreign key constraint checking. Returns true if successful.
override
execute(QueryPlan plan) Future<List<Map<String, Object?>>>
Resolves plan into raw rows where each map represents one record.
executeRaw(String sql, [List<Object?> parameters = const []]) Future<void>
Executes an arbitrary SQL statement that does not return rows.
getCurrentSchema() Future<String>
Gets the current schema/namespace being used.
override
hasColumn(String table, String column, {String? schema}) Future<bool>
Determines if the given table has a specific column.
override
hasColumns(String table, List<String> columns, {String? schema}) Future<bool>
Determines if the given table has all of the specified columns.
override
hasIndex(String table, String index, {String? schema, String? type}) Future<bool>
Determines if the given table has a specific index. Optionally check by index type ('primary', 'unique', or specific driver type).
override
hasTable(String table, {String? schema}) Future<bool>
Determines if the given table exists.
override
hasView(String view, {String? schema}) Future<bool>
Determines if the given view exists.
override
listColumns(String table, {String? schema}) Future<List<SchemaColumn>>
Lists columns for table within an optional schema.
override
listDatabases() Future<List<String>>
Lists all databases/catalogs accessible to the current connection.
override
listForeignKeys(String table, {String? schema}) Future<List<SchemaForeignKey>>
Lists foreign keys for table within an optional schema.
override
listIndexes(String table, {String? schema}) Future<List<SchemaIndex>>
Lists indexes for table within an optional schema.
override
listSchemas() Future<List<SchemaNamespace>>
Lists the schemas/namespaces available in the connection.
override
listTables({String? schema}) Future<List<SchemaTable>>
Lists all user tables on the connection, optionally filtered by schema.
override
listViews({String? schema}) Future<List<SchemaView>>
Lists all views on the connection, optionally filtered by schema.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
queryRaw(String sql, [List<Object?> parameters = const []]) Future<List<Map<String, Object?>>>
Executes a raw SQL query and returns the resulting rows.
rollbackTransaction() Future<void>
Rolls back the active database transaction.
runMutation(MutationPlan plan) Future<MutationResult>
Executes a structured mutation plan (insert/update/delete).
setCurrentSchema(String name) Future<void>
Sets the current schema/namespace for operations.
override
stream(QueryPlan plan) Stream<Map<String, Object?>>
Streams rows for plan. Drivers may override to avoid buffering.
threadCount() Future<int?>
Returns the number of open connections reported by the backend, when supported.
toString() String
A string representation of this object.
inherited
transaction<R>(Future<R> action()) Future<R>
Starts a new transaction boundary.
truncateTable(String tableName) Future<void>
Truncates a table, removing all rows and resetting auto-increment counters.
withoutForeignKeyConstraints<T>(Future<T> callback()) Future<T>
Executes a callback with foreign key constraints disabled. Automatically re-enables constraints after callback completes.
override

Operators

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

Static Methods

registerCodecs() → void
Registers PostgreSQL-specific codecs and type mapper with the global registries. Call this once during application initialization before using PostgreSQL.