Future
executeQuery(String formatString, Map<String, dynamic> values, int timeoutInSeconds, { PersistentStoreQueryReturnType returnType: PersistentStoreQueryReturnType.rows })
Source
@override
Future<dynamic> executeQuery(
String formatString, Map<String, dynamic> values, int timeoutInSeconds,
{PersistentStoreQueryReturnType returnType:
PersistentStoreQueryReturnType.rows}) async {
var now = new DateTime.now().toUtc();
try {
var dbConnection = await getDatabaseConnection();
var results;
if (returnType == PersistentStoreQueryReturnType.rows) {
results = await dbConnection
.query(formatString, substitutionValues: values)
.timeout(new Duration(seconds: timeoutInSeconds));
} else {
results = await dbConnection
.execute(formatString, substitutionValues: values)
.timeout(new Duration(seconds: timeoutInSeconds));
}
logger.fine(() =>
"Query (${(new DateTime.now().toUtc().difference(now).inMilliseconds)}ms) $formatString Substitutes: ${values ?? "{}"} -> $results");
return results;
} on TimeoutException catch (e) {
throw new QueryException(QueryExceptionEvent.connectionFailure,
underlyingException: e);
} on PostgreSQLException catch (e) {
logger.fine(() =>
"Query (${(new DateTime.now().toUtc().difference(now).inMilliseconds)}ms) $formatString $values");
throw _interpretException(e);
}
}