buildSql method

String buildSql(
  1. String table
)

---------- SQL ----------

Implementation

String buildSql(String table) {
  final selectSql =
      selectColumns != null && selectColumns!.isNotEmpty
          ? selectColumns!.join(', ')
          : '*';

  final distinctSql = distinctValue ? 'DISTINCT ' : '';
  final joinSql = joins.isNotEmpty ? ' ${joins.join(' ')} ' : '';
  final whereSql = where != null ? ' WHERE $where' : '';
  final groupSql = groupByColumns.isNotEmpty
      ? ' GROUP BY ${groupByColumns.join(', ')}'
      : '';
  final orderSql =
      orderByClause != null ? ' ORDER BY $orderByClause' : '';
  final limitSql = limitValue != null ? ' LIMIT $limitValue' : '';
  final offsetSql =
      offsetValue != null && limitValue != null
          ? ' OFFSET $offsetValue'
          : '';

  return 'SELECT $distinctSql$selectSql FROM $table$joinSql$whereSql$groupSql$orderSql$limitSql$offsetSql;';
}