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

Query: Fixes native c# parser not recognizing query with multiple IN statements #2451

Merged
merged 6 commits into from
May 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,21 @@ public override SqlObject VisitLogical_scalar_expression([NotNull] sqlParser.Log
}
else
{
throw new NotImplementedException();
// logical_expression binary_operator logical_expression
Contract.Requires(context.ChildCount == 3);

SqlScalarExpression left = (SqlScalarExpression)this.Visit(context.logical_scalar_expression(0));

if (!CstToAstVisitor.binaryOperatorKindLookup.TryGetValue(
context.children[1].GetText(),
out SqlBinaryScalarOperatorKind operatorKind))
{
throw new ArgumentOutOfRangeException($"Unknown logical operator: {context.children[1].GetText()}.");
}

SqlScalarExpression right = (SqlScalarExpression)this.Visit(context.logical_scalar_expression(1));

sqlObject = SqlBinaryScalarExpression.Create(operatorKind, left, right);
}

return sqlObject;
Expand Down
4 changes: 2 additions & 2 deletions Microsoft.Azure.Cosmos/src/Query/Core/Parser/sql.g4
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ logical_scalar_expression
: binary_scalar_expression
| in_scalar_expression
| like_scalar_expression
| logical_scalar_expression K_AND logical_scalar_expression
| logical_scalar_expression K_OR logical_scalar_expression
;

in_scalar_expression
Expand All @@ -112,8 +114,6 @@ binary_scalar_expression
| binary_scalar_expression bitwise_and_operator binary_scalar_expression
| binary_scalar_expression bitwise_exclusive_or_operator binary_scalar_expression
| binary_scalar_expression bitwise_inclusive_or_operator binary_scalar_expression
| binary_scalar_expression K_AND binary_scalar_expression
| binary_scalar_expression K_OR binary_scalar_expression
| binary_scalar_expression string_concat_operator binary_scalar_expression
;

Expand Down
Loading