AmrDeveloper / GQL

Git Query language is a SQL like language to perform queries on .git files with supports of most of SQL features such as grouping, ordering and aggregations functions
https://amrdeveloper.github.io/GQL/
MIT License
3.3k stars 90 forks source link

Incorrect statement for CASE in documentation #77

Closed craftslab closed 9 months ago

craftslab commented 9 months ago

Describe the bug

Incorrect statement for CASE in documentation

To Reproduce

// https://github.com/AmrDeveloper/GQL/blob/master/docs/expression/case.md
SELECT name FROM branches WHERE (CASE WHERE isRemote THEN 1 ELSE 0 END) > 0

Expected behavior

SELECT name FROM branches WHERE (CASE WHEN isRemote THEN 1 ELSE 0 END) > 0 // replace WHERE with WHEN

GQL (please complete the following information):

Version 0.13.0

Screenshots

FireShot Capture 136 - Case - Git Query language - amrdeveloper github io

craftslab commented 9 months ago

Please check parser.rs @AmrDeveloper

https://github.com/AmrDeveloper/GQL/blob/f9d61c979d25fbafaa8fe99836efc3140e239cad/crates/gitql-parser/src/parser.rs#L1868C20-L1868C23

// Check if current token kind is WHEN keyword`
let when_result = consume_kind(tokens, *position, TokenKind::When);
if when_result.is_err() {
    return Err(Diagnostic::error("Expect `when` before case condition")
        .add_help("Try to add `WHEN` keyword before any condition")
        .with_location(get_safe_location(tokens, *position))
        .as_boxed());
}
AmrDeveloper commented 9 months ago

Hello @craftslab,

Thank you for reporting,i fixed it and docs is correct no

Thank you, Amr