toSql method

String toSql()

Implementation

String toSql() {
  String str = '';

  if (direction == JoinDirection.left) {
    str += 'LEFT JOIN';
  } else if (direction == JoinDirection.right) {
    str += 'RIGHT JOIN';
  } else {
    str += 'JOIN';
  }

  if (type == JoinType.normal) {
    str += ' $table ON $column1 = $column2';

    return str;
  }

  if (type == JoinType.subquery) {
    str += ' (' + subQuery!.toSql() + ') as $alias ON $column1 = $column2';

    return str;
  }

  //str += '$table ON $column1 = $column2';

  if (innerClause == null) {
    throw Exception('Si es clause no puede tener inner clause null');
  }

  str += ' $table ' + innerClause!.toSql();

  return str;
}