selfCrossJoin method

Query selfCrossJoin(
  1. dynamic tableName, {
  2. dynamic baseColumnName,
  3. dynamic columnName,
  4. Query function(
    1. Query q,
    2. String tableName,
    3. String baseTableName
    )?,
})

Implementation

Query selfCrossJoin(tableName, {baseColumnName, columnName, Query Function(Query q, String tableName, String baseTableName)? function}) {
  if (function != null) {
    final rand = getRandomString(9);
    _joinQuery += ' CROSS JOIN $tableName $rand ON ';
    final que = Query(table: tableName);
    que.table = tableName;
    que._self = true;
    Query q = function(que, tableName, rand);
    _select += q._select;
    _joinQuery += q._joinQuery.replaceAll('{TABLE_COLUMN_FILL}', rand) + ' ' + q._lastQuery.replaceAll('WHERE', 'AND');
  } else {
    final rand = getRandomString(9);
    _joinQuery += ' CROSS JOIN $tableName $rand ON ';
    _joinQuery += tableName + '.' + columnName;
    _joinQuery += '=';
    _joinQuery += rand + '.' + baseColumnName;
  }
  return this;
}