isSqlTrue method

dynamic isSqlTrue(
  1. dynamic strSql,
  2. dynamic context
)

Implementation

isSqlTrue(strSql, context) {
  myLogAll('isSqlTrue');
  if (strSql.toString() == gFalse) {
    return false;
  }
  bool isExists = true;
  if (strSql.toString().startsWith(gHaveRight)) {
    String sRole = strSql
        .toString()
        .substring(gHaveRight.length, strSql.toString().indexOf(')'));
    isExists = getHaveRight(sRole, context);
    if (!isExists) {
      return false;
    }

    strSql = strSql.toString().substring(strSql.toString().indexOf(')') + 1);
    if (strSql.toString().startsWith(' && ')) {
      strSql = strSql.toString().substring(4);
    }
    if (isNull(strSql)) {
      return isExists;
    }
  }
  List fromS = strSql.toString().split(" from ");

  isExists = !fromS[0].toString().contains("not exists");

  dynamic sqlResult = getSqlResult(strSql, context);
  if (!isNull(sqlResult)) {
    if (isExists) {
      return true;
    }
    return false;
  } else {
    if (isExists) {
      return false;
    }
    return true;
  }
}