selfJoin method
Query
selfJoin(
- dynamic tableName, {
- dynamic columnName,
- dynamic baseColumnName,
- Query function(
- Query q,
- String tableName,
- String baseTableName
)?,
})
Implementation
Query selfJoin(tableName, {columnName, baseColumnName, Query Function(Query q, String tableName, String baseTableName)? function}) {
if (function != null) {
final rand = getRandomString(9);
_joinQuery += ' INNER JOIN $tableName $rand ON ';
Query q = function(Query(table: tableName), tableName, rand);
q._self = false;
q.table = table;
_select += q._select;
_joinQuery += q._joinQuery.replaceAll('{TABLE_COLUMN_FILL}', rand) + ' ' + q._lastQuery.replaceAll('WHERE', 'AND');
} else {
final rand = getRandomString(9);
_joinQuery += ' INNER JOIN $tableName $rand ON ';
_joinQuery += tableName + '.' + columnName;
_joinQuery += '=';
_joinQuery += rand + '.' + baseColumnName;
}
return this;
}