Skip to content

Commit

Permalink
fix: add settings to postgresql open (#70)
Browse files Browse the repository at this point in the history
* fix: add settings to postgresql open

* default settings
  • Loading branch information
davidlondono authored Dec 4, 2024
1 parent 131a0b3 commit 72667b2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
20 changes: 11 additions & 9 deletions packages/athena_postgres/lib/src/athena_postgres_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,18 @@ class PostgreSQLDriver extends PostgreTransactionSQLDriver<pg.Connection>
PostgreSQLDriver._(super.connection) : super._();

/// Opens a connection to the database
static Future<PostgreSQLDriver> open(AthenaPostgresqlEndpoint config) async {
static Future<PostgreSQLDriver> open(AthenaPostgresqlEndpoint endpoint,
{AthenaConnectionSettings settings =
const AthenaConnectionSettings()}) async {
final connection = await pg.Connection.open(
pg.Endpoint(
host: config.host,
database: config.databaseName,
port: config.port,
username: config.username,
password: config.password,
),
);
pg.Endpoint(
host: endpoint.host,
database: endpoint.databaseName,
port: endpoint.port,
username: endpoint.username,
password: endpoint.password,
),
settings: settings);
return PostgreSQLDriver._(connection);
}

Expand Down
22 changes: 22 additions & 0 deletions packages/athena_postgres/lib/src/database_config.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'package:postgres/postgres.dart';

/// PostgreSQL Endpoint for connecting to a PostgreSQL database.
class AthenaPostgresqlEndpoint {
/// PostgreSQL Endpoint for connecting to a PostgreSQL database.
Expand All @@ -24,3 +26,23 @@ class AthenaPostgresqlEndpoint {
/// Password for authenticating this connection.
final String? password;
}

/// Connection settings for connecting to a PostgreSQL database.
class AthenaConnectionSettings extends ConnectionSettings {
/// Connection settings for connecting to a PostgreSQL database.
const AthenaConnectionSettings({
super.applicationName,
super.connectTimeout,
super.encoding,
super.ignoreSuperfluousParameters,
super.onOpen,
super.queryMode,
super.queryTimeout,
super.replicationMode,
super.securityContext,
super.sslMode,
super.timeZone,
super.transformer,
super.typeRegistry,
});
}

0 comments on commit 72667b2

Please sign in to comment.