From cdca9756909f8954f374dbb78fd643437324427f Mon Sep 17 00:00:00 2001 From: David Londono Date: Fri, 29 Nov 2024 11:35:27 -0500 Subject: [PATCH] comments on postgresql and mysql --- .idea/runConfigurations/melos_run_format.xml | 11 -- .../athena_migrate/lib/athena_migrate.dart | 5 - packages/athena_migrate/pubspec.yaml | 4 +- packages/athena_mysql/analysis_options.yaml | 30 ---- packages/athena_mysql/example/main.dart | 2 +- packages/athena_mysql/lib/athena_mysql.dart | 8 +- .../lib/src/athena_mysql_base.dart | 37 +++-- .../lib/src/builders/column_options.dart | 6 +- .../lib/src/builders/data_types.dart | 53 ++++-- .../athena_mysql/lib/src/database_config.dart | 33 +++- packages/athena_mysql/lib/src/mapper.dart | 42 +++-- packages/athena_mysql/pubspec.yaml | 8 +- packages/athena_mysql/test/connection.dart | 6 +- .../athena_postgres/analysis_options.yaml | 30 ---- packages/athena_postgres/example/main.dart | 2 +- .../athena_postgres/lib/athena_postgres.dart | 5 +- .../lib/src/athena_postgres_base.dart | 37 +++-- .../lib/src/builders/column_options.dart | 6 +- .../lib/src/builders/data_types.dart | 156 +++++++++++------- .../lib/src/database_config.dart | 71 +------- packages/athena_postgres/pubspec.yaml | 8 +- .../test/athena_postgres_test.dart | 6 +- .../athena_postgres/test/columns_test.dart | 4 +- packages/athena_postgres/test/docker.dart | 4 +- .../athena_postgres/test/insert_test.dart | 4 +- packages/athena_sql/pubspec.yaml | 2 +- packages/athena_utils/pubspec.yaml | 4 +- 27 files changed, 277 insertions(+), 307 deletions(-) delete mode 100644 .idea/runConfigurations/melos_run_format.xml delete mode 100644 packages/athena_mysql/analysis_options.yaml delete mode 100644 packages/athena_postgres/analysis_options.yaml diff --git a/.idea/runConfigurations/melos_run_format.xml b/.idea/runConfigurations/melos_run_format.xml deleted file mode 100644 index 04ba109..0000000 --- a/.idea/runConfigurations/melos_run_format.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - diff --git a/packages/athena_migrate/lib/athena_migrate.dart b/packages/athena_migrate/lib/athena_migrate.dart index 4df47ad..bc7bafa 100644 --- a/packages/athena_migrate/lib/athena_migrate.dart +++ b/packages/athena_migrate/lib/athena_migrate.dart @@ -1,8 +1,3 @@ -/// Support for doing something awesome. -/// -/// More dartdocs go here. -library athena_migrate; - export 'src/athena_migrate_base.dart'; // TODO: Export any libraries intended for clients of this package. diff --git a/packages/athena_migrate/pubspec.yaml b/packages/athena_migrate/pubspec.yaml index e084f9e..5b160f5 100644 --- a/packages/athena_migrate/pubspec.yaml +++ b/packages/athena_migrate/pubspec.yaml @@ -5,11 +5,11 @@ homepage: https://docs.athena-sql.dev/migration/ repository: https://github.com/athena-sql/athena_sql/tree/master/packages/athena_migrate environment: - sdk: '>=3.5.0 <4.0.0' + sdk: '>=3.0.0 <4.0.0' dev_dependencies: build_runner: ^2.3.0 - lints: ^2.0.0 + lints: ^5.0.0 mockito: ^5.4.0 test: ^1.21.0 dependencies: diff --git a/packages/athena_mysql/analysis_options.yaml b/packages/athena_mysql/analysis_options.yaml deleted file mode 100644 index dee8927..0000000 --- a/packages/athena_mysql/analysis_options.yaml +++ /dev/null @@ -1,30 +0,0 @@ -# This file configures the static analysis results for your project (errors, -# warnings, and lints). -# -# This enables the 'recommended' set of lints from `package:lints`. -# This set helps identify many issues that may lead to problems when running -# or consuming Dart code, and enforces writing Dart using a single, idiomatic -# style and format. -# -# If you want a smaller set of lints you can change this to specify -# 'package:lints/core.yaml'. These are just the most critical lints -# (the recommended set includes the core lints). -# The core lints are also what is used by pub.dev for scoring packages. - -include: package:lints/recommended.yaml - -# Uncomment the following section to specify additional rules. - -# linter: -# rules: -# - camel_case_types - -# analyzer: -# exclude: -# - path/to/excluded/files/** - -# For more information about the core and recommended set of lints, see -# https://dart.dev/go/core-lints - -# For additional information about configuring this file, see -# https://dart.dev/guides/language/analysis-options diff --git a/packages/athena_mysql/example/main.dart b/packages/athena_mysql/example/main.dart index c8227ed..11e61d5 100644 --- a/packages/athena_mysql/example/main.dart +++ b/packages/athena_mysql/example/main.dart @@ -1,7 +1,7 @@ import 'package:athena_mysql/athena_mysql.dart'; void main(List args) async { - final athenaSql = await AthenaMySQL.open(AthenaMySqlEndpoint( + final athenaSql = await AthenaMySQL.open(const AthenaMySqlEndpoint( host: 'localgost', port: 3306, userName: 'userName', diff --git a/packages/athena_mysql/lib/athena_mysql.dart b/packages/athena_mysql/lib/athena_mysql.dart index 43687f6..fcfdf6b 100644 --- a/packages/athena_mysql/lib/athena_mysql.dart +++ b/packages/athena_mysql/lib/athena_mysql.dart @@ -1,9 +1,5 @@ -/// Support for doing something awesome. -/// -/// More dartdocs go here. -library athena_mysql; +export 'package:athena_sql/athena_sql.dart'; export 'src/athena_mysql_base.dart'; -export 'src/database_config.dart'; export 'src/builders/builders.dart'; -export 'package:athena_sql/athena_sql.dart'; +export 'src/database_config.dart'; diff --git a/packages/athena_mysql/lib/src/athena_mysql_base.dart b/packages/athena_mysql/lib/src/athena_mysql_base.dart index 0c5fd0a..a3fe22b 100644 --- a/packages/athena_mysql/lib/src/athena_mysql_base.dart +++ b/packages/athena_mysql/lib/src/athena_mysql_base.dart @@ -1,14 +1,17 @@ -import 'package:athena_mysql/src/mapper.dart'; import 'package:athena_sql/athena_sql.dart'; import 'package:mysql_client/mysql_client.dart'; import 'database_config.dart'; +import 'mapper.dart'; +/// Represents a MySQL connection endpoint. abstract class AthenaMySQLException implements Exception { - final String message; - + /// Creates a new AthenaMySQLException with the given message. const AthenaMySQLException(this.message); + /// The message for this exception. + final String message; + String get _prefix; @override @@ -17,19 +20,25 @@ abstract class AthenaMySQLException implements Exception { } } +/// Represents a MySQL connection endpoint. class AthenaMySQLNoConnectionException extends AthenaMySQLException { + /// Creates a new AthenaMySQLNoConnectionException with the given message. const AthenaMySQLNoConnectionException( - [super.message = "No connection found"]); + [super.message = 'No connection found']); @override String get _prefix => 'AthenaMySQLConnectionException'; } +/// Represents a MySQL connection endpoint. class MySqlTransactionSQLDriver extends AthenaDatabaseDriver { + MySqlTransactionSQLDriver._(this.connection); + + /// The connection to the database MySQLConnection connection; bool _isOpen = false; - MySqlTransactionSQLDriver._(this.connection); + /// Opens a new connection to the database. static Future open( AthenaMySqlEndpoint endpoint) async { final connection = await MySQLConnection.createConnection( @@ -76,7 +85,7 @@ class MySqlTransactionSQLDriver extends AthenaDatabaseDriver { Map? mapValues, bool? iterable, }) async { - final mapper = QueryMapper(numered: false, prefixQuery: '?'); + final mapper = QueryMapper(prefixQuery: '?'); final queryToExecute = mapper.getValues(queryString, mapValues ?? {}); if (queryToExecute.args.isEmpty) { @@ -102,21 +111,24 @@ class MySqlTransactionSQLDriver extends AthenaDatabaseDriver { } } +/// Column options for MySQL Driver class MySqlColumnsDriver extends AthenaColumnsDriver { @override - ColumnDef boolean() => ColumnDef('BOOLEAN'); + ColumnDef boolean() => const ColumnDef('BOOLEAN'); @override - ColumnDef integer() => ColumnDef('INTEGER'); + ColumnDef integer() => const ColumnDef('INTEGER'); @override - ColumnDef string() => ColumnDef('VARCHAR', parameters: ['255']); + ColumnDef string() => const ColumnDef('VARCHAR', parameters: ['255']); } +/// MySQL driver for Athena class MySqlDriver extends MySqlTransactionSQLDriver implements AthenaDatabaseConnectionDriver { - MySqlDriver._(MySQLConnection connection) : super._(connection); + MySqlDriver._(super.connection) : super._(); + /// Opens a new connection to the database. static Future open(AthenaMySqlEndpoint endpoint) async { final connection = await MySQLConnection.createConnection( host: endpoint.host, @@ -148,14 +160,17 @@ class MySqlDriver extends MySqlTransactionSQLDriver } } +/// MySQL Athena connection class AthenaMySQL extends AthenaSQL { - AthenaMySQL._(MySqlDriver driver) : super(driver); + AthenaMySQL._(super.driver); + /// Athena MySQL connection static Future open(AthenaMySqlEndpoint endpoint) async { final driver = await MySqlDriver.open(endpoint); return AthenaMySQL._(driver); } + /// Creates a new AthenaMySQL instance from a map connection static Future fromMapConnection( Map connection) async { final config = AthenaMySqlEndpoint.fromMap(connection); diff --git a/packages/athena_mysql/lib/src/builders/column_options.dart b/packages/athena_mysql/lib/src/builders/column_options.dart index 13b8bf7..211489d 100644 --- a/packages/athena_mysql/lib/src/builders/column_options.dart +++ b/packages/athena_mysql/lib/src/builders/column_options.dart @@ -1,15 +1,19 @@ import 'package:athena_sql/athena_sql.dart'; -import 'package:athena_sql/schemas.dart'; import 'package:athena_sql/query_printable.dart'; +import 'package:athena_sql/schemas.dart'; +/// Column options for Athena typedef CSBuilder = AthenaQueryBuilder; +/// Column options for Athena extension ColumnOptionsBuilder on CSBuilder { + /// Set Compression for the column CSBuilder compression(String compression) { return $addingPreContrains( QueryString().keyword('COMPRESSION ').userInput(compression)); } + /// Set Collate for the column CSBuilder collate(String collate) { return $addingPreContrains( QueryString().keyword('COLLATE ').userInput(collate)); diff --git a/packages/athena_mysql/lib/src/builders/data_types.dart b/packages/athena_mysql/lib/src/builders/data_types.dart index f523e98..9616902 100644 --- a/packages/athena_mysql/lib/src/builders/data_types.dart +++ b/packages/athena_mysql/lib/src/builders/data_types.dart @@ -1,105 +1,128 @@ import 'package:athena_sql/athena_sql.dart'; import 'package:athena_sql/schemas.dart'; +/// Integer Data Types extension IntegerDataTypes on AthenaQueryBuilder { + /// Create a column with type TINYINT AthenaQueryBuilder tinyint(String name) => $customType(name, type: 'TINYINT'); + /// Create a column with type SMALLINT AthenaQueryBuilder smallint(String name) => $customType(name, type: 'SMALLINT'); + /// Create a column with type MEDIUMINT AthenaQueryBuilder mediumint(String name) => - $customType(name, type: "MEDIUMINT"); + $customType(name, type: 'MEDIUMINT'); + /// Create a column with type INT AthenaQueryBuilder int_(String name) => - $customType(name, type: "INT"); + $customType(name, type: 'INT'); AthenaQueryBuilder _fixedPointType(String name, String type, [int? digits, int? decimals]) { - assert(digits == null || digits > 0); - assert(digits == null || digits < 65); - assert(decimals == null || decimals > 0); + assert(digits == null || digits > 0, 'digits must be greater than 0'); + assert(digits == null || digits < 65, 'digits must be less than 65'); + assert(decimals == null || decimals > 0, 'decimals must be greater than 0'); // assert if decimals is not null, digits must be not null - assert(digits != null || decimals == null); + assert(digits != null || decimals == null, + 'digits must be not null if decimals is not null'); return $customType(name, type: type, parameters: ['$digits', if (decimals != null) '$decimals']); } + /// Create a column with type DECIMAL AthenaQueryBuilder decimal(String name, [int? digits, int? decimals]) => _fixedPointType(name, 'DECIMAL', digits, decimals); + /// Create a column with type NUMERIC AthenaQueryBuilder numeric(String name, [int? digits, int? decimals]) => _fixedPointType(name, 'NUMERIC', digits, decimals); } +/// Floating Point Data Types extension FixedPointDataTypes on AthenaQueryBuilder { AthenaQueryBuilder _fixedPointType(String name, String type, [int? digits, int? decimals]) { - assert(digits == null || digits > 0); - assert(digits == null || digits < 65); - assert(decimals == null || decimals > 0); + assert(digits == null || digits > 0, 'digits must be greater than 0'); + assert(digits == null || digits < 65, 'digits must be less than 65'); + assert(decimals == null || decimals > 0, 'decimals must be greater than 0'); // assert if decimals is not null, digits must be not null - assert(digits != null || decimals == null); + assert(digits != null || decimals == null, + 'digits must be not null if decimals is not null'); return $customType(name, type: type, parameters: [ if (digits != null) '$digits', if (digits != null && decimals != null) '$decimals' ]); } + /// Create a column with type DECIMAL AthenaQueryBuilder decimal(String name, [int? digits, int? decimals]) => _fixedPointType(name, 'DECIMAL', digits, decimals); + /// Create a column with type NUMERIC AthenaQueryBuilder numeric(String name, [int? digits, int? decimals]) => _fixedPointType(name, 'NUMERIC', digits, decimals); + /// Create a column with type DEC AthenaQueryBuilder dec(String name, [int? digits, int? decimals]) => _fixedPointType(name, 'DEC', digits, decimals); + /// Create a column with type FIXED AthenaQueryBuilder fixed(String name, [int? digits, int? decimals]) => _fixedPointType(name, 'FIXED', digits, decimals); } +/// Floating Point Data Types extension FloatingPointDataTypes on AthenaQueryBuilder { AthenaQueryBuilder _floatingPointType( String name, String type, [int? precision, int? decimals]) { - assert(precision == null || precision > 0); - assert(precision == null || precision < 53); - assert(decimals == null || decimals > 0); + assert( + precision == null || precision > 0, 'precision must be greater than 0'); + assert( + precision == null || precision < 53, 'precision must be less than 53'); + assert(decimals == null || decimals > 0, 'decimals must be greater than 0'); // assert if decimals is not null, digits must be not null - assert(precision != null || decimals == null); + assert(precision != null || decimals == null, + 'precision must be not null if decimals is not null'); return $customType(name, type: type, parameters: [ if (precision != null) '$precision', if (precision != null && decimals != null) '$decimals' ]); } + /// Create a column with type FLOAT AthenaQueryBuilder float(String name, [int? precision, int? decimals]) => _floatingPointType(name, 'FLOAT', precision, decimals); + /// Create a column with type DOUBLE AthenaQueryBuilder double(String name, [int? precision, int? decimals]) => _floatingPointType(name, 'DOUBLE', precision, decimals); + /// Create a column with type DOUBLE PRECISION AthenaQueryBuilder doublePrecision(String name, [int? precision, int? decimals]) => _floatingPointType(name, 'DOUBLE PRECISION', precision, decimals); } +/// Bits Data Types extension BitValueDataTypes on AthenaQueryBuilder { + /// Create a column with type BIT AthenaQueryBuilder bit(String name, int values) { - assert(values >= 1 || values <= 64); + assert(values >= 1 || values <= 64, 'values must be between 1 and 64'); return $customType(name, type: 'BIT', parameters: ['$values']); } } diff --git a/packages/athena_mysql/lib/src/database_config.dart b/packages/athena_mysql/lib/src/database_config.dart index abce49a..a580bf6 100644 --- a/packages/athena_mysql/lib/src/database_config.dart +++ b/packages/athena_mysql/lib/src/database_config.dart @@ -1,4 +1,6 @@ +/// Configuration for a MySQL database. class AthenaMySqlEndpoint { + /// Configuration for a MySQL database. const AthenaMySqlEndpoint({ required this.host, required this.port, @@ -9,14 +11,7 @@ class AthenaMySqlEndpoint { this.collation = 'utf8mb4_general_ci', }); - final dynamic host; - final int port; - final String userName; - final String password; - final bool secure; - final String? databaseName; - final String collation; - + /// Creates a new MySQL endpoint from a map. factory AthenaMySqlEndpoint.fromMap(Map map) { final host = map['host'] ?? 'localhost'; final port = map['port'] ?? 3306; @@ -33,6 +28,28 @@ class AthenaMySqlEndpoint { ); } + /// Hostname of database this connection refers to. + final dynamic host; + + /// Port of database this connection refers to. + final int port; + + /// Username for authenticating this connection. + final String userName; + + /// Password for authenticating this connection. + final String password; + + /// Whether to use a secure connection. + final bool secure; + + /// Name of database this connection refers to. + final String? databaseName; + + /// Collation to use for the connection. + final String collation; + + /// Creates a new MySQL endpoint with a different database. AthenaMySqlEndpoint copyWithDatabase(String? database) { return AthenaMySqlEndpoint( host: host, diff --git a/packages/athena_mysql/lib/src/mapper.dart b/packages/athena_mysql/lib/src/mapper.dart index fc98a57..7647810 100644 --- a/packages/athena_mysql/lib/src/mapper.dart +++ b/packages/athena_mysql/lib/src/mapper.dart @@ -1,9 +1,6 @@ enum _TokeType { text, variable } class _TokenConent { - _TokeType type; - var content = StringBuffer(); - _TokenConent(this.type); _TokenConent.variable(int char) : type = _TokeType.variable { addChar(char); @@ -11,6 +8,8 @@ class _TokenConent { _TokenConent.text(int char) : type = _TokeType.text { addChar(char); } + _TokeType type; + StringBuffer content = StringBuffer(); void addChar(int char) { content.writeCharCode(char); @@ -18,35 +17,39 @@ class _TokenConent { } class _TokenIdentifier { + _TokenIdentifier(this.name, this.typeCast); final String name; final String? typeCast; - - _TokenIdentifier(this.name, this.typeCast); } class _QueryNameArguments { + _QueryNameArguments(this.query, this.argsMap); final String query; final List argsMap; - - _QueryNameArguments(this.query, this.argsMap); } +/// Represents a query to execute class QueryToExecute { + /// Creates a query to execute + const QueryToExecute(this.query, this.args); + + /// The query to execute final String query; - final List args; - QueryToExecute(this.query, this.args); + /// The arguments to pass to the query + final List args; } +/// Maps a query to a query to execute class QueryMapper { - final int _prefixCode; - final bool _numered; - final String _prefixQuery; - + /// Creates a query mapper QueryMapper({String? signCode, bool numered = false, String? prefixQuery}) : _prefixCode = (signCode ?? '@').codeUnitAt(0), _numered = numered, - _prefixQuery = prefixQuery ?? '\$'; + _prefixQuery = prefixQuery ?? r'$'; + final int _prefixCode; + final bool _numered; + final String _prefixQuery; static bool _isIdentifier(int charCode) { return (charCode >= _lowercaseACodeUnit && @@ -92,8 +95,9 @@ class QueryMapper { if (iter.current == _prefixCode) { iter.movePrevious(); if (iter.current == _prefixCode) { - currentPtr.addChar(iter.current); - currentPtr.type = _TokeType.text; + currentPtr + ..addChar(iter.current) + ..type = _TokeType.text; } else { currentPtr = _TokenConent.variable(iter.current); items.add(currentPtr); @@ -116,7 +120,7 @@ class QueryMapper { final components = t.split('::'); if (components.length > 1) { - typeCast = components.sublist(1).join(''); + typeCast = components.sublist(1).join(); } final variableComponents = components.first.split(':'); @@ -126,6 +130,7 @@ class QueryMapper { name = variableComponents.first; } else { throw FormatException( + // ignore: lines_longer_than_80_chars "Invalid format string identifier, must contain identifier name and optionally one data type in format '@identifier:dataType' (offending identifier: $t)"); } @@ -156,11 +161,12 @@ class QueryMapper { } return val; } - }).join(''); + }).join(); return _QueryNameArguments(content, args); } + /// Gets the values of a query QueryToExecute getValues(String query, Map values) { final tokens = _getTokenized(query); final built = _generateBuilder(tokens); diff --git a/packages/athena_mysql/pubspec.yaml b/packages/athena_mysql/pubspec.yaml index f2fe01b..06dd938 100644 --- a/packages/athena_mysql/pubspec.yaml +++ b/packages/athena_mysql/pubspec.yaml @@ -10,14 +10,14 @@ topics: - sql - mysql environment: - sdk: '>=3.5.0 <4.0.0' + sdk: '>=3.0.0 <4.0.0' dependencies: - path: ^1.8.3 athena_sql: ^1.1.8 mysql_client: ^0.0.27 + path: ^1.8.3 dev_dependencies: - lints: ^2.0.0 - test: ^1.21.0 docker_process: ^1.3.1 + lints: ^5.0.0 + test: ^1.21.0 diff --git a/packages/athena_mysql/test/connection.dart b/packages/athena_mysql/test/connection.dart index b7e277b..d878c2b 100644 --- a/packages/athena_mysql/test/connection.dart +++ b/packages/athena_mysql/test/connection.dart @@ -1,5 +1,3 @@ -library mysql1.test.test_infrastructure; - // import 'package:options_file/options_file.dart'; // import 'package:mysql1/mysql1.dart'; import 'package:athena_mysql/athena_mysql.dart'; @@ -9,9 +7,9 @@ AthenaMySQL get conn => _conn!; AthenaMySQL? _conn; void useConnection([String? tableName, String? createSql, String? insertSql]) { - final db = 'testdb'; + const db = 'testdb'; - final endpoint = AthenaMySqlEndpoint( + const endpoint = AthenaMySqlEndpoint( host: '127.0.0.1', port: 3306, userName: 'root', diff --git a/packages/athena_postgres/analysis_options.yaml b/packages/athena_postgres/analysis_options.yaml deleted file mode 100644 index dee8927..0000000 --- a/packages/athena_postgres/analysis_options.yaml +++ /dev/null @@ -1,30 +0,0 @@ -# This file configures the static analysis results for your project (errors, -# warnings, and lints). -# -# This enables the 'recommended' set of lints from `package:lints`. -# This set helps identify many issues that may lead to problems when running -# or consuming Dart code, and enforces writing Dart using a single, idiomatic -# style and format. -# -# If you want a smaller set of lints you can change this to specify -# 'package:lints/core.yaml'. These are just the most critical lints -# (the recommended set includes the core lints). -# The core lints are also what is used by pub.dev for scoring packages. - -include: package:lints/recommended.yaml - -# Uncomment the following section to specify additional rules. - -# linter: -# rules: -# - camel_case_types - -# analyzer: -# exclude: -# - path/to/excluded/files/** - -# For more information about the core and recommended set of lints, see -# https://dart.dev/go/core-lints - -# For additional information about configuring this file, see -# https://dart.dev/guides/language/analysis-options diff --git a/packages/athena_postgres/example/main.dart b/packages/athena_postgres/example/main.dart index fff2921..b7a25fc 100644 --- a/packages/athena_postgres/example/main.dart +++ b/packages/athena_postgres/example/main.dart @@ -1,7 +1,7 @@ import 'package:athena_postgres/athena_postgres.dart'; void main(List args) async { - final athenaSql = await AthenaPostgresql.open(AthenaPostgresqlEndpoint( + final athenaSql = await AthenaPostgresql.open(const AthenaPostgresqlEndpoint( host: 'localhost', databaseName: 'postgres', username: 'postgres', diff --git a/packages/athena_postgres/lib/athena_postgres.dart b/packages/athena_postgres/lib/athena_postgres.dart index c32a60d..8a805cd 100644 --- a/packages/athena_postgres/lib/athena_postgres.dart +++ b/packages/athena_postgres/lib/athena_postgres.dart @@ -3,7 +3,8 @@ /// More dartdocs go here. library athena_postgres; +export 'package:athena_sql/athena_sql.dart'; + export 'src/athena_postgres_base.dart'; -export 'src/database_config.dart'; export 'src/builders/builders.dart'; -export 'package:athena_sql/athena_sql.dart'; +export 'src/database_config.dart'; diff --git a/packages/athena_postgres/lib/src/athena_postgres_base.dart b/packages/athena_postgres/lib/src/athena_postgres_base.dart index f72ea4d..269ddfa 100644 --- a/packages/athena_postgres/lib/src/athena_postgres_base.dart +++ b/packages/athena_postgres/lib/src/athena_postgres_base.dart @@ -5,11 +5,14 @@ import 'package:postgres/postgres.dart' as pg; import 'database_config.dart'; +/// Query driver for Postgres class PostgreTransactionSQLDriver extends AthenaDatabaseDriver { - T connection; PostgreTransactionSQLDriver._(this.connection); + /// The connection to the database + T connection; + @override Future tableExists(String table, {String schema = 'public'}) async { final result = await connection.execute(pg.Sql.named(''' @@ -22,7 +25,7 @@ class PostgreTransactionSQLDriver ); '''), parameters: {'schema': schema, 'table': table}); - return result.first.first as bool; + return result.first.first! as bool; } @override @@ -48,29 +51,32 @@ class PostgreTransactionSQLDriver @override String mapColumnOrTable(String column) { - final vals = column.split("."); + final vals = column.split('.'); return [ for (final val in vals) - if (val.contains(RegExp(r'[A-Z]'))) '"$val"' else val - ].join("."); + if (val.contains(RegExp('[A-Z]'))) '"$val"' else val + ].join('.'); } } +/// Columns driver for Postgres class PostgresColumnsDriver extends AthenaColumnsDriver { @override - ColumnDef boolean() => ColumnDef('BOOLEAN'); + ColumnDef boolean() => const ColumnDef('BOOLEAN'); @override - ColumnDef integer() => ColumnDef('INTEGER'); + ColumnDef integer() => const ColumnDef('INTEGER'); @override - ColumnDef string() => ColumnDef('VARCHAR'); + ColumnDef string() => const ColumnDef('VARCHAR'); } +/// Driver for Postgres class PostgreSQLDriver extends PostgreTransactionSQLDriver implements AthenaDatabaseConnectionDriver { - PostgreSQLDriver._(pg.Connection connection) : super._(connection); + PostgreSQLDriver._(super.connection) : super._(); + /// Opens a connection to the database static Future open(AthenaPostgresqlEndpoint config) async { final connection = await pg.Connection.open( pg.Endpoint( @@ -101,15 +107,19 @@ class PostgreSQLDriver extends PostgreTransactionSQLDriver } } +/// Athena Postgres SQL class AthenaPostgresql extends AthenaSQL { AthenaPostgresql._(pg.Connection config) : super(PostgreSQLDriver._(config)); + /// Opens a connection to the database static Future open(AthenaPostgresqlEndpoint config) async { final driver = await PostgreSQLDriver.open(config); return AthenaPostgresql._(driver.connection); } static final _listenings = {}; + + /// Listens to a channel Stream listen(String channel) { if (!_listenings.contains(channel)) { unawaited(rawQuery('listen $channel')); @@ -121,25 +131,28 @@ class AthenaPostgresql extends AthenaSQL { } } +/// map secure getters extension MapSecure on Map { + /// Gets a value from the map T? optionalValue(String key) { if (!containsKey(key)) { return null; } final val = this[key]; if (val is! T) { - throw Exception('Key \'$key\' is not of type ${T.toString()}'); + throw Exception("Key '$key' is not of type ${T.toString()}"); } return this[key] as T; } + /// Gets a value from the map T getValue(String key) { if (!containsKey(key)) { - throw Exception('Key \'$key\' not found'); + throw Exception("Key '$key' not found"); } final val = this[key]; if (val is! T) { - throw Exception('Key \'$key\' is not of type ${T.toString()}'); + throw Exception("Key '$key' is not of type ${T.toString()}"); } return this[key] as T; } diff --git a/packages/athena_postgres/lib/src/builders/column_options.dart b/packages/athena_postgres/lib/src/builders/column_options.dart index 13b8bf7..b4d0440 100644 --- a/packages/athena_postgres/lib/src/builders/column_options.dart +++ b/packages/athena_postgres/lib/src/builders/column_options.dart @@ -1,15 +1,19 @@ import 'package:athena_sql/athena_sql.dart'; -import 'package:athena_sql/schemas.dart'; import 'package:athena_sql/query_printable.dart'; +import 'package:athena_sql/schemas.dart'; +/// Column Builder for Postgres typedef CSBuilder = AthenaQueryBuilder; +/// Column Options Builder for Postgres extension ColumnOptionsBuilder on CSBuilder { + /// set compression to column CSBuilder compression(String compression) { return $addingPreContrains( QueryString().keyword('COMPRESSION ').userInput(compression)); } + /// set collate to column CSBuilder collate(String collate) { return $addingPreContrains( QueryString().keyword('COLLATE ').userInput(collate)); diff --git a/packages/athena_postgres/lib/src/builders/data_types.dart b/packages/athena_postgres/lib/src/builders/data_types.dart index 7ff776c..f010494 100644 --- a/packages/athena_postgres/lib/src/builders/data_types.dart +++ b/packages/athena_postgres/lib/src/builders/data_types.dart @@ -1,7 +1,7 @@ import 'package:athena_sql/athena_sql.dart'; import 'package:athena_sql/schemas.dart'; -class PostgresDataTypes { +class _PostgresDataTypes { static const bigint = 'BIGINT'; static const int8 = 'INT8'; static const bigserial = 'BIGSERIAL'; @@ -61,145 +61,181 @@ class PostgresDataTypes { static const xml = 'XML'; } +/// Postgres specific data types enum IntervalPhrases { + /// interval of years year('YEAR'), + + /// interval of months month('MONTH'), + + /// interval of days day('DAY'), + + /// interval of hours hour('HOUR'), + + /// interval of minutes minute('MINUTE'), + + /// interval of seconds second('SECOND'), + + /// interval of years to months yearToMonth('YEAR TO MONTH'), + + /// interval of days to hours dayToHour('DAY TO HOUR'), + + /// interval of days to minutes dayToMinute('DAY TO MINUTE'), + + /// interval of days to seconds dayToSecond('DAY TO SECOND'), + + /// interval of hours to minutes hourToMinute('HOUR TO MINUTE'), + + /// interval of hours to seconds hourToSecond('HOUR TO SECOND'), + + /// interval of minutes to seconds minuteToSecond('MINUTE TO SECOND'); - final String name; const IntervalPhrases(this.name); + + /// name of the interval + final String name; } +/// Postgres specific data types enum TimeOption { + /// with time zone withTimeZone('WITH TIME ZONE'), + + /// without time zone withoutTimeZone('WITHOUT TIME ZONE'); - final String value; const TimeOption(this.value); + + /// local time zone + final String value; } +/// Add create columns types for Postgres extension PostgresColumnBuilder on AthenaQueryBuilder { /// signed eight-byte integer /// /// *(alias: `int8`)* AthenaQueryBuilder bigint(String name) => - $customType(name, type: PostgresDataTypes.bigint); + $customType(name, type: _PostgresDataTypes.bigint); /// signed eight-byte integer AthenaQueryBuilder int8(String name) => - $customType(name, type: PostgresDataTypes.int8); + $customType(name, type: _PostgresDataTypes.int8); /// autoincrementing eight-byte integer /// /// *(alias: `serial8`)* AthenaQueryBuilder bigserial(String name) => - $customType(name, type: PostgresDataTypes.bigserial); + $customType(name, type: _PostgresDataTypes.bigserial); /// autoincrementing eight-byte integer AthenaQueryBuilder serial8(String name) => - $customType(name, type: PostgresDataTypes.serial8); + $customType(name, type: _PostgresDataTypes.serial8); /// fixed-length bit string AthenaQueryBuilder bit(String name, int n) => - $customType(name, type: PostgresDataTypes.bit, parameters: ['$n']); + $customType(name, type: _PostgresDataTypes.bit, parameters: ['$n']); /// variable-length bit string AthenaQueryBuilder bitVarying(String name, int n) => - $customType(name, type: PostgresDataTypes.bitVarying, parameters: ['$n']); + $customType(name, + type: _PostgresDataTypes.bitVarying, parameters: ['$n']); /// variable-length bit string AthenaQueryBuilder varbit(String name, int n) => - $customType(name, type: PostgresDataTypes.varbit, parameters: ['$n']); + $customType(name, type: _PostgresDataTypes.varbit, parameters: ['$n']); /// logical Boolean (true/false) /// /// *(alias: `bool`)* AthenaQueryBuilder boolean(String name) => - $customType(name, type: PostgresDataTypes.boolean); + $customType(name, type: _PostgresDataTypes.boolean); /// logical Boolean (true/false) AthenaQueryBuilder bool(String name) => - $customType(name, type: PostgresDataTypes.bool); + $customType(name, type: _PostgresDataTypes.bool); /// rectangular box on a plane AthenaQueryBuilder box(String name) => - $customType(name, type: PostgresDataTypes.box); + $customType(name, type: _PostgresDataTypes.box); /// binary data (“byte array”) AthenaQueryBuilder bytea(String name) => - $customType(name, type: PostgresDataTypes.bytea); + $customType(name, type: _PostgresDataTypes.bytea); /// **fixed-length character string** /// /// *(alias: char [ `(n)` ])* AthenaQueryBuilder character(String name, int n) => - $customType(name, type: PostgresDataTypes.character, parameters: ['$n']); + $customType(name, type: _PostgresDataTypes.character, parameters: ['$n']); /// fixed-length character string AthenaQueryBuilder char(String name, int n) => - $customType(name, type: PostgresDataTypes.char, parameters: ['$n']); + $customType(name, type: _PostgresDataTypes.char, parameters: ['$n']); /// variable-length character string /// /// *(alias: `varchar [ (n) ]`)* AthenaQueryBuilder characterVarying(String name, int n) => $customType(name, - type: PostgresDataTypes.characterVarying, parameters: ['$n']); + type: _PostgresDataTypes.characterVarying, parameters: ['$n']); /// variable-length character string AthenaQueryBuilder varchar(String name, int n) => - $customType(name, type: PostgresDataTypes.varchar, parameters: ['$n']); + $customType(name, type: _PostgresDataTypes.varchar, parameters: ['$n']); ///IPv4 or IPv6 network address AthenaQueryBuilder cidr(String name) => - $customType(name, type: PostgresDataTypes.cidr); + $customType(name, type: _PostgresDataTypes.cidr); ///circle on a plane AthenaQueryBuilder circle(String name) => - $customType(name, type: PostgresDataTypes.circle); + $customType(name, type: _PostgresDataTypes.circle); ///calendar date (year, month, day) AthenaQueryBuilder date(String name) => - $customType(name, type: PostgresDataTypes.date); + $customType(name, type: _PostgresDataTypes.date); ///double precision floating-point number (8 bytes) /// ///*(alias: `float8`)* AthenaQueryBuilder doublePrecision(String name) => - $customType(name, type: PostgresDataTypes.doublePrecision); + $customType(name, type: _PostgresDataTypes.doublePrecision); ///double precision floating-point number (8 bytes) AthenaQueryBuilder float8(String name) => - $customType(name, type: PostgresDataTypes.float8); + $customType(name, type: _PostgresDataTypes.float8); ///IPv4 or IPv6 host address AthenaQueryBuilder inet(String name) => - $customType(name, type: PostgresDataTypes.inet); + $customType(name, type: _PostgresDataTypes.inet); ///signed four-byte integer /// ///*(alias: `int`, `int4`)* AthenaQueryBuilder integer(String name) => - $customType(name, type: PostgresDataTypes.integer); + $customType(name, type: _PostgresDataTypes.integer); ///signed four-byte integer AthenaQueryBuilder int_(String name) => - $customType(name, type: PostgresDataTypes.int); + $customType(name, type: _PostgresDataTypes.int); ///signed four-byte integer AthenaQueryBuilder int4(String name) => - $customType(name, type: PostgresDataTypes.int4); + $customType(name, type: _PostgresDataTypes.int4); ///time span AthenaQueryBuilder interval(String name, @@ -214,146 +250,146 @@ extension PostgresColumnBuilder } return $customType(name, - type: PostgresDataTypes.interval, posParameters: posParameters); + type: _PostgresDataTypes.interval, posParameters: posParameters); } ///JSON data AthenaQueryBuilder json(String name) => - $customType(name, type: PostgresDataTypes.json); + $customType(name, type: _PostgresDataTypes.json); ///binary JSON data, decomposed AthenaQueryBuilder jsonb(String name) => - $customType(name, type: PostgresDataTypes.jsonb); + $customType(name, type: _PostgresDataTypes.jsonb); ///infinite line on a plane AthenaQueryBuilder line(String name) => - $customType(name, type: PostgresDataTypes.line); + $customType(name, type: _PostgresDataTypes.line); ///line segment on a plane AthenaQueryBuilder lseg(String name) => - $customType(name, type: PostgresDataTypes.lseg); + $customType(name, type: _PostgresDataTypes.lseg); ///MAC (Media Access Control) address AthenaQueryBuilder macaddr(String name) => - $customType(name, type: PostgresDataTypes.macaddr); + $customType(name, type: _PostgresDataTypes.macaddr); ///MAC (Media Access Control) address (EUI-64 format) AthenaQueryBuilder macaddr8(String name) => - $customType(name, type: PostgresDataTypes.macaddr8); + $customType(name, type: _PostgresDataTypes.macaddr8); ///currency amount AthenaQueryBuilder money(String name) => - $customType(name, type: PostgresDataTypes.money); + $customType(name, type: _PostgresDataTypes.money); ///exact numeric of selectable precision AthenaQueryBuilder numeric(String name, int p, int s) => $customType(name, - type: PostgresDataTypes.numeric, parameters: ['$p', '$s']); + type: _PostgresDataTypes.numeric, parameters: ['$p', '$s']); ///exact numeric of selectable precision AthenaQueryBuilder decimal(String name, int p, int s) => $customType(name, - type: PostgresDataTypes.decimal, parameters: ['$p', '$s']); + type: _PostgresDataTypes.decimal, parameters: ['$p', '$s']); ///geometric path on a plane AthenaQueryBuilder path(String name) => - $customType(name, type: PostgresDataTypes.path); + $customType(name, type: _PostgresDataTypes.path); ///PostgreSQL Log Sequence Number AthenaQueryBuilder pgLsn(String name) => - $customType(name, type: PostgresDataTypes.pgLsn); + $customType(name, type: _PostgresDataTypes.pgLsn); ///user-level transaction ID snapshot AthenaQueryBuilder pgSnapshot(String name) => - $customType(name, type: PostgresDataTypes.pgSnapshot); + $customType(name, type: _PostgresDataTypes.pgSnapshot); ///geometric point on a plane AthenaQueryBuilder point(String name) => - $customType(name, type: PostgresDataTypes.point); + $customType(name, type: _PostgresDataTypes.point); ///geometric polygon on a plane AthenaQueryBuilder polygon(String name) => - $customType(name, type: PostgresDataTypes.polygon); + $customType(name, type: _PostgresDataTypes.polygon); ///single precision floating-point number (4 bytes) AthenaQueryBuilder real(String name) => - $customType(name, type: PostgresDataTypes.real); + $customType(name, type: _PostgresDataTypes.real); ///single precision floating-point number (4 bytes) AthenaQueryBuilder float4(String name) => - $customType(name, type: PostgresDataTypes.float4); + $customType(name, type: _PostgresDataTypes.float4); ///signed two-byte integer AthenaQueryBuilder smallint(String name) => - $customType(name, type: PostgresDataTypes.smallint); + $customType(name, type: _PostgresDataTypes.smallint); ///signed two-byte integer AthenaQueryBuilder int2(String name) => - $customType(name, type: PostgresDataTypes.int2); + $customType(name, type: _PostgresDataTypes.int2); ///autoincrementing two-byte integer AthenaQueryBuilder smallserial(String name) => - $customType(name, type: PostgresDataTypes.smallserial); + $customType(name, type: _PostgresDataTypes.smallserial); ///autoincrementing two-byte integer AthenaQueryBuilder serial2(String name) => - $customType(name, type: PostgresDataTypes.serial2); + $customType(name, type: _PostgresDataTypes.serial2); ///autoincrementing four-byte integer AthenaQueryBuilder serial(String name) => - $customType(name, type: PostgresDataTypes.serial); + $customType(name, type: _PostgresDataTypes.serial); ///autoincrementing four-byte integer AthenaQueryBuilder serial4(String name) => - $customType(name, type: PostgresDataTypes.serial4); + $customType(name, type: _PostgresDataTypes.serial4); ///variable-length character string AthenaQueryBuilder text(String name) => - $customType(name, type: PostgresDataTypes.text); + $customType(name, type: _PostgresDataTypes.text); ///time of day (no time zone) AthenaQueryBuilder time(String name, {int? p, TimeOption? option}) => $customType(name, - type: PostgresDataTypes.time, + type: _PostgresDataTypes.time, parameters: p != null ? ['$p'] : null, posParameters: option != null ? [option.value] : null); ///time of day, including time zone AthenaQueryBuilder timetz(String name, {int? p}) => $customType(name, - type: PostgresDataTypes.timetz, + type: _PostgresDataTypes.timetz, parameters: p != null ? ['$p'] : null); ///date and time AthenaQueryBuilder timestamp(String name, {int? p, TimeOption? option}) => $customType(name, - type: PostgresDataTypes.timestamp, + type: _PostgresDataTypes.timestamp, parameters: p != null ? ['$p'] : null, posParameters: option != null ? [option.value] : null); ///date and time, including time zone AthenaQueryBuilder timestamptz(String name) => - $customType(name, type: PostgresDataTypes.timestamptz); + $customType(name, type: _PostgresDataTypes.timestamptz); ///text search query AthenaQueryBuilder tsquery(String name) => - $customType(name, type: PostgresDataTypes.tsquery); + $customType(name, type: _PostgresDataTypes.tsquery); ///text search document AthenaQueryBuilder tsvector(String name) => - $customType(name, type: PostgresDataTypes.tsvector); + $customType(name, type: _PostgresDataTypes.tsvector); ///user-level transaction ID snapshot (deprecated; see pg_snapshot) AthenaQueryBuilder txidSnapshot(String name) => - $customType(name, type: PostgresDataTypes.txidSnapshot); + $customType(name, type: _PostgresDataTypes.txidSnapshot); ///universally unique identifier AthenaQueryBuilder uuid(String name) => - $customType(name, type: PostgresDataTypes.uuid); + $customType(name, type: _PostgresDataTypes.uuid); ///XML data AthenaQueryBuilder xml(String name) => - $customType(name, type: PostgresDataTypes.xml); + $customType(name, type: _PostgresDataTypes.xml); } diff --git a/packages/athena_postgres/lib/src/database_config.dart b/packages/athena_postgres/lib/src/database_config.dart index edd2771..077bdcb 100644 --- a/packages/athena_postgres/lib/src/database_config.dart +++ b/packages/athena_postgres/lib/src/database_config.dart @@ -1,7 +1,7 @@ -import 'package:postgres/postgres.dart'; - +/// PostgreSQL Endpoint for connecting to a PostgreSQL database. class AthenaPostgresqlEndpoint { - AthenaPostgresqlEndpoint({ + /// PostgreSQL Endpoint for connecting to a PostgreSQL database. + const AthenaPostgresqlEndpoint({ required this.host, this.port = 5432, required this.databaseName, @@ -24,68 +24,3 @@ class AthenaPostgresqlEndpoint { /// Password for authenticating this connection. final String? password; } - -class PostgresDatabaseConfig { - PostgresDatabaseConfig( - this.host, - this.port, - this.databaseName, { - this.username, - this.password, - this.timeoutInSeconds = 30, - this.queryTimeoutInSeconds = 30, - this.timeZone = 'UTC', - this.useSSL = false, - this.isUnixSocket = false, - this.allowClearTextPassword = false, - this.replicationMode = ReplicationMode.none, - }); - - /// Hostname of database this connection refers to. - final String host; - - /// Port of database this connection refers to. - final int port; - - /// Name of database this connection refers to. - final String databaseName; - - /// Username for authenticating this connection. - final String? username; - - /// Password for authenticating this connection. - final String? password; - - /// Whether or not this connection should connect securely. - final bool useSSL; - - /// The amount of time this connection will wait during connecting before giving up. - final int timeoutInSeconds; - - /// The default timeout for [PostgreSQLExecutionContext]'s execute and query methods. - final int queryTimeoutInSeconds; - - /// The timezone of this connection for date operations that don't specify a timezone. - final String timeZone; - - /// If true, connection is made via unix socket. - final bool isUnixSocket; - - /// If true, allows password in clear text for authentication. - final bool allowClearTextPassword; - - /// The replication mode for connecting in streaming replication mode. - /// - /// When the value is set to either [ReplicationMode.physical] or [ReplicationMode.logical], - /// the query protocol will no longer work as the connection will be switched to a replication - /// connection. In other words, using the default [query] or [mappedResultsQuery] will cause - /// the database to throw an error and drop the connection. - /// - /// Use [query] `useSimpleQueryProtocol` set to `true` or [execute] for executing statements - /// while in replication mode. - /// - /// For more info, see [Streaming Replication Protocol] - /// - /// [Streaming Replication Protocol]: https://www.postgresql.org/docs/current/protocol-replication.html - final ReplicationMode replicationMode; -} diff --git a/packages/athena_postgres/pubspec.yaml b/packages/athena_postgres/pubspec.yaml index 646e95c..beb54ae 100644 --- a/packages/athena_postgres/pubspec.yaml +++ b/packages/athena_postgres/pubspec.yaml @@ -10,14 +10,14 @@ topics: - postgres environment: - sdk: '>=3.5.0 <4.0.0' + sdk: '>=3.0.0 <4.0.0' dependencies: + athena_sql: ^1.1.8 path: ^1.8.3 postgres: ^3.4.4 - athena_sql: ^1.1.8 dev_dependencies: - lints: ^2.0.0 - test: ^1.21.0 docker_process: ^1.3.1 + lints: ^5.0.0 + test: ^1.21.0 diff --git a/packages/athena_postgres/test/athena_postgres_test.dart b/packages/athena_postgres/test/athena_postgres_test.dart index 30486b9..65a0b80 100644 --- a/packages/athena_postgres/test/athena_postgres_test.dart +++ b/packages/athena_postgres/test/athena_postgres_test.dart @@ -9,7 +9,7 @@ void main() { late AthenaPostgresql athena; setUp(() async { - athena = await AthenaPostgresql.open(AthenaPostgresqlEndpoint( + athena = await AthenaPostgresql.open(const AthenaPostgresqlEndpoint( host: 'localhost', databaseName: 'dart_test', username: 'postgres', @@ -17,10 +17,10 @@ void main() { )); // Additional setup goes here. }); - tearDown(() async => await athena.close()); + tearDown(() async => athena.close()); test('execute query', () async { - final tableName = 'create_table_test'; + const tableName = 'create_table_test'; final completed = await athena.create .table(tableName) .column((t) => t.int_('id').primaryKey()) diff --git a/packages/athena_postgres/test/columns_test.dart b/packages/athena_postgres/test/columns_test.dart index 396e5cf..bca3484 100644 --- a/packages/athena_postgres/test/columns_test.dart +++ b/packages/athena_postgres/test/columns_test.dart @@ -11,7 +11,7 @@ void main() { setUp(() async { print('open'); - athena = await AthenaPostgresql.open(AthenaPostgresqlEndpoint( + athena = await AthenaPostgresql.open(const AthenaPostgresqlEndpoint( host: 'localhost', databaseName: 'dart_test', username: 'postgres', @@ -20,7 +20,7 @@ void main() { print('opened'); // Additional setup goes here. }); - tearDown(() async => await athena.close()); + tearDown(() async => athena.close()); test('execute query', () async { print('testing'); diff --git a/packages/athena_postgres/test/docker.dart b/packages/athena_postgres/test/docker.dart index 7ecdf56..96717fb 100644 --- a/packages/athena_postgres/test/docker.dart +++ b/packages/athena_postgres/test/docker.dart @@ -19,10 +19,8 @@ void usePostgresDocker() { final dp = await startPostgres( name: _kContainerName, version: 'latest', - pgPort: 5432, pgDatabase: 'postgres', pgUser: 'postgres', - pgPassword: 'postgres', cleanup: true, configurations: [ // SSL settings @@ -37,7 +35,7 @@ void usePostgresDocker() { // Setup the database to support all kind of tests // see _setupDatabaseStatements definition for details - for (var stmt in _setupDatabaseStatements) { + for (final stmt in _setupDatabaseStatements) { final args = [ 'psql', '-c', diff --git a/packages/athena_postgres/test/insert_test.dart b/packages/athena_postgres/test/insert_test.dart index 44ac1f3..b171980 100644 --- a/packages/athena_postgres/test/insert_test.dart +++ b/packages/athena_postgres/test/insert_test.dart @@ -9,7 +9,7 @@ void main() { late AthenaPostgresql athena; setUpAll(() async { - athena = await AthenaPostgresql.open(AthenaPostgresqlEndpoint( + athena = await AthenaPostgresql.open(const AthenaPostgresqlEndpoint( host: 'localhost', databaseName: 'dart_test', username: 'postgres', @@ -32,7 +32,7 @@ void main() { RESTART IDENTITY; '''); }); - tearDownAll(() async => await athena.close()); + tearDownAll(() async => athena.close()); test('execute query', () async { final inserted = await athena.insert.into('users').values({ diff --git a/packages/athena_sql/pubspec.yaml b/packages/athena_sql/pubspec.yaml index 6ac1c6d..a82701e 100644 --- a/packages/athena_sql/pubspec.yaml +++ b/packages/athena_sql/pubspec.yaml @@ -6,7 +6,7 @@ homepage: https://docs.athena-sql.dev/ repository: https://github.com/athena-sql/athena_sql/ environment: - sdk: '>=3.5.0 <4.0.0' + sdk: '>=3.0.0 <4.0.0' dependencies: collection: ^1.19.1 diff --git a/packages/athena_utils/pubspec.yaml b/packages/athena_utils/pubspec.yaml index 4652fa0..19afa6c 100644 --- a/packages/athena_utils/pubspec.yaml +++ b/packages/athena_utils/pubspec.yaml @@ -6,10 +6,10 @@ homepage: https://docs.athena-sql.dev/utils/ repository: https://github.com/athena-sql/athena_sql/tree/master/packages/athena_utils environment: - sdk: '>=3.5.0 <4.0.0' + sdk: '>=3.0.0 <4.0.0' dev_dependencies: - lints: ^2.0.0 + lints: ^5.0.0 test: ^1.21.0 dependencies: file: ^7.0.1