toSelectSql method

String toSelectSql()

Implementation

String toSelectSql() {
  distinct = distinct || joins.any((element) => element.distinct);

  var where = [
    conditions.toSql(wrap: false),
    ...joins.map((e) => e.conditions.toSql(wrap: false))
  ].where((element) => element.isNotEmpty).join(' AND ');

  if (where.isNotEmpty) where = 'where $where';
  return [
    'select',
    distinct ? 'distinct' : '',
    columns.join(', '),
    'from',
    tableName,
    alias,
    joins.toSql(),
    where,
  ].where((element) => element.isNotEmpty).join(' ');
}