openQuery method
Implementation
@override
Future<Either<ErrorSqlResult, SelectSuccesSqlResult>> openQuery(
String methodName, String sql) async {
var _dbConnection = newConnection();
try {
if ((_dbConnection is PostgreSQLConnection) && (_dbConnection.isClosed)) {
await _dbConnection.open();
}
return right(pgQueryToSelectSuccesSqlResult(
className, methodName, sql, (await _dbConnection.query(sql))));
} on PostgreSQLException catch (e) {
try {
_dbConnection.cancelTransaction(reason: e.toString());
} on Exception {
// ignore
}
return left(pgExceptionToErrorSqlResult(className, methodName, sql, e));
} catch (e) {
try {
_dbConnection.cancelTransaction(reason: e.toString());
} on Exception {
// ignore
}
return left(ErrorSqlResult(className, methodName, sql, [e.toString()]));
} finally {
if ((_dbConnection is PostgreSQLConnection) &&
(!_dbConnection.isClosed)) {
await _dbConnection.close();
}
}
}