support using a different grammar with LogicalQueryParser.search#9
support using a different grammar with LogicalQueryParser.search#9scambra wants to merge 1 commit intokanety:masterfrom
Conversation
|
I see my change breaks usage with associations in ruby 2.x, but ruby 2 is EOL, do you want to keep supporting those versions? For example, this is broken for all versions: But this way works for ruby 3.x, I changed a spec in this way to fix tests on ruby 3.x: To have it working in ruby 2.x, this way is required, which is a bit weird: I can change the spec to use |
|
I found another way to provide a parser, which works with ruby 2.x, and also works if the model has a parser association. It doesn't change the syntax when no parser is provided. If another parser is provided, it requires to use |
|
As 0.5.0 requires ruby >= 3, I changed the code to support providing a parser, without breaking any existing code using LogicalQueryParser.search. I copied the existing specs for search, and added parser option |
There are cases where I want to use a simpler grammar, for example one which only supports words and quoted words, and use AND to find results with all tokens, or another grammar which uses OR to find results with any token.
With this option, I was able to do it writting a grammar (treetop file and modules with to_sql methods), but still use the search method and the association resolver.