diff --git a/sbroad-core/src/frontend/sql.rs b/sbroad-core/src/frontend/sql.rs index bf07e211e322ca458dbf10ad2e0263252198a2ac..9e9ef44fb37ab5af0c236c4f1343584b17ad36e3 100644 --- a/sbroad-core/src/frontend/sql.rs +++ b/sbroad-core/src/frontend/sql.rs @@ -2681,7 +2681,7 @@ where Rule::GtEq => ParseExpressionInfixOperator::InfixBool(Bool::GtEq), Rule::In => { let mut op_inner = op.into_inner(); - is_not = op_inner.next().is_some(); + is_not = op_inner.next().is_some_and(|i| matches!(i.as_rule(), Rule::NotFlag)); ParseExpressionInfixOperator::InfixBool(Bool::In) } Rule::Subtract => ParseExpressionInfixOperator::InfixArithmetic(Arithmetic::Subtract), diff --git a/sbroad-core/src/frontend/sql/ir/tests.rs b/sbroad-core/src/frontend/sql/ir/tests.rs index e74f6d26ebbfb3d718968f322965028834efd024..da851c65d26b4663e67b569fd5cb97c3e705096c 100644 --- a/sbroad-core/src/frontend/sql/ir/tests.rs +++ b/sbroad-core/src/frontend/sql/ir/tests.rs @@ -548,6 +548,16 @@ fn front_sql_between_invalid() { } } +#[test] +fn front_sql_parse_inner_join() { + let input = r#"SELECT * FROM "hash_testing" + left join "hash_testing" on true inner join "hash_testing" on true"#; + + // Check there are no panics + let _ = sql_to_optimized_ir(input, vec![]); + assert_eq!(true, true) +} + #[test] fn front_sql_check_arbitrary_utf_in_single_quote_strings() { let input = r#"SELECT "identification_number" FROM "hash_testing" diff --git a/sbroad-core/src/frontend/sql/query.pest b/sbroad-core/src/frontend/sql/query.pest index e85a4de839b087070be9c64eb696b46b12cd3871..b51f70ab9751344759f1098092a3695d7d24d442 100644 --- a/sbroad-core/src/frontend/sql/query.pest +++ b/sbroad-core/src/frontend/sql/query.pest @@ -303,7 +303,8 @@ Expr = { ExprAtomValue ~ (ExprInfixOp ~ ExprAtomValue)* } Lt = { "<" } LtEq = { "<=" } NotEq = { "<>" | "!=" } - In = { NotFlag? ~ ^"in" } + In = { NotFlag? ~ InAtom } + InAtom = @{ ^"in" ~ SP } ExprAtomValue = _{ UnaryNot* ~ AtomicExpr ~ CastPostfix* ~ IsNullPostfix? } UnaryNot = @{ NotFlag } CastPostfix = { "::" ~ ColumnDefType }