generateCountSQL method
FutureOr<SQL>
generateCountSQL(
- Transaction transaction,
- String entityName,
- String table, {
- EntityMatcher? matcher,
- Object? parameters,
- List? positionalParameters,
- Map<
String, Object?> ? namedParameters,
Implementation
FutureOr<SQL> generateCountSQL(
Transaction transaction, String entityName, String table,
{EntityMatcher? matcher,
Object? parameters,
List? positionalParameters,
Map<String, Object?>? namedParameters}) {
var q = dialect.elementQuote;
if (matcher == null) {
var sqlQuery = 'SELECT count(*) as ${q}count$q FROM $q$table$q ';
return SQL(
sqlQuery,
positionalParameters ?? (parameters is List ? parameters : null),
namedParameters ??
(parameters is Map<String, dynamic> ? parameters : null),
{},
mainTable: table,
);
} else {
return _generateSQLFrom(transaction, entityName, table, matcher,
parameters: parameters,
positionalParameters: positionalParameters,
namedParameters: namedParameters,
sqlBuilder: (String from, EncodingContext context) {
return 'SELECT count(*) as ${q}count$q $from';
});
}
}