query method
Runs a statement or command and returns a normalized result.
SQL drivers generally treat statement as SQL. Document database drivers
can define their own command naming convention, such as
collection.operation.
Implementation
@override
Future<AnySqlResult> query(
String statement, {
Map<String, Object?> parameters = const {},
}) async {
_checkOpen();
try {
final result = await connection.execute(
parameters.isEmpty ? pg.Sql(statement) : pg.Sql.named(statement),
parameters: parameters.isEmpty ? null : parameters,
);
return _postgresResult(result);
} on AnySqlException {
rethrow;
} on Object catch (error) {
throw AnySqlQueryException(
'Failed to execute PostgreSQL query: ${statementPreview(statement)}',
error,
);
}
}