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

Invalid parse while combining AND and OR clauses #44

Closed
antoine-de opened this issue Nov 4, 2024 · 2 comments · Fixed by #47
Closed

Invalid parse while combining AND and OR clauses #44

antoine-de opened this issue Nov 4, 2024 · 2 comments · Fixed by #47
Labels
bug Something isn't working

Comments

@antoine-de
Copy link

antoine-de commented Nov 4, 2024

Hi, thanks a lot for this project.

I try using it, but I'm stuck with what I think is an invalid parsing.

Here is a minimal example:

use cql2::Expr;

pub fn main() {
    let s = "(floors>5 AND material='brick') OR swimming_pool=true";

    let query = s.parse::<Expr>().expect("should be valid query");

    assert_eq!(
        query.to_text().unwrap(),
        r#"(("floors" > 5) AND ("material" = 'brick')) OR ("swimming_pool" = true)"#
    );
}
thread 'main' panicked at examples/test.rs:8:5:
assertion `left == right` failed
  left: "((\"floors\" > 5) AND (\"material\" = 'brick') AND (\"swimming_pool\" = true))"
 right: "((\"floors\" > 5) AND (\"material\" = 'brick')) OR (\"swimming_pool\" = true)"

The AND/OR combination becomes only 2 AND.

The example is from fixtures/test/example17.txt: (floors>5 AND material='brick') OR swimming_pool=true, but strangely it's not the same as the tests/expected/text/example17.txt (and I think it's because this file is generated).

@gadomski gadomski added the bug Something isn't working label Nov 4, 2024
@gadomski gadomski assigned gadomski and unassigned gadomski Nov 4, 2024
gadomski added a commit that referenced this issue Nov 4, 2024
@gadomski
Copy link
Collaborator

gadomski commented Nov 4, 2024

@bitner I took a stab but I don't grok the parser well enough ATM, so I'm unassigning myself. I put a failing test up in #45.

@antoine-de
Copy link
Author

great, thanks, it works as expected 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants