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

DefaultOperator not applied to all terms in GenerateQueryVisitor #76

Closed
richardcockerill opened this issue Oct 11, 2023 · 3 comments
Closed
Assignees
Labels

Comments

@richardcockerill
Copy link
Contributor

If I set the default operator on the context on a call to GenerateQueryVisitor.Run then the operator is only being applied to the left side of the first GroupNode in the graph.

eg

IQueryNode parsedQuery = await parser.ParseAsync("term1 term2 term3);
var context = new QueryVisitorContext { DefaultOperator = GroupOperator.And };
string result = GenerateQueryVisitor.Run(parsedQuery, context); 

produces "term1 AND term2 term3" but should be "term1 AND term2 AND term3"

GenerateQueryVisitor needs to apply the operator to every GroupNode but this is not happening because GenerateQueryVisitor delegates to GroupNode.ToString(GroupOperator defaultOperator) which then just invokes ToString on the Left and Right.

Tests and a fix attached

GenerateQueryVisitorDefaultOperator.patch

@niemyjski
Copy link
Member

Thanks for reporting this! Would it be possible to create a pr for this given your patch.

richardcockerill added a commit to richardcockerill/Foundatio.Parsers that referenced this issue Oct 12, 2023
… side of group node in GenerateQueryVisitor
@richardcockerill
Copy link
Contributor Author

Thanks for responding, PR #77 created @niemyjski

ejsmith pushed a commit that referenced this issue Oct 12, 2023
…oup node in GenerateQueryVisitor (#77)

Co-authored-by: Richard Cockerill <5318261+richardcockerill@users.noreply.github.com>
@niemyjski
Copy link
Member

Thanks again for the PR!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants