Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When pass any not exist filter, the Sieve ignore all filters and sorts. #193

Open
kostazol opened this issue Jul 18, 2023 · 0 comments
Open

Comments

@kostazol
Copy link

After some researching, I found the problem - missing try/catch block in the ApplyFiltering method. This block exist in the Apply method, because of it when we pass a filter that doesn't exist in a model and doesn't exist in custom filters, we got exception SieveMethodNotFoundException in the ApplyCustomMethod method.
Because of it when we pass any not exist filter, the Sieve will ignore all filters and sorts, because it will be finished applying in catch block.

   public IQueryable<TEntity> Apply<TEntity>(
      TSieveModel model,
      IQueryable<TEntity> source,
      object[] dataForCustomMethods = null,
      bool applyFiltering = true,
      bool applySorting = true,
      bool applyPagination = true)
    {
      IQueryable<TEntity> result = source;
      if ((object) model == null)
        return result;
      try
      {
        if (applyFiltering)
          result = this.ApplyFiltering<TEntity>(model, result, dataForCustomMethods);
        if (applySorting)
          result = this.ApplySorting<TEntity>(model, result, dataForCustomMethods);
        if (applyPagination)
          result = this.ApplyPagination<TEntity>(model, result);
        return result;
      }
      catch (Exception ex)
      {
        if (!this.Options.Value.ThrowExceptions)
          return result;
        if (!(ex is SieveException))
          throw new SieveException(ex.Message, ex);
        throw;
      }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant