![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
logical_query_parser
Advanced tools
A parser to generate a tree structure from a logical search query string using treetop.
Add this line to your application's Gemfile:
gem 'logical_query_parser'
And then execute:
$ bundle
Or install it yourself as:
$ gem install logical_query_parser
You can parse a logical query string as follows:
parser = LogicalQueryParser.new
parser.parse('a AND b')
# return value is a syntax tree of treetop
=> SyntaxNode+Exp0+ExpNode offset=0, "a AND b" (any):
SyntaxNode+Cond0+CondNode offset=0, "a AND b" (lexp,logic,rexp):
SyntaxNode+Literal0+LiteralNode offset=0, "a" (word,negative):
SyntaxNode offset=0, ""
SyntaxNode+WordNode offset=0, "a":
SyntaxNode+Atom0 offset=0, "a":
SyntaxNode offset=0, ""
SyntaxNode offset=0, "a"
SyntaxNode offset=1, " ":
SyntaxNode offset=1, " "
SyntaxNode+AndNode offset=2, "AND"
SyntaxNode offset=5, " ":
SyntaxNode offset=5, " "
SyntaxNode+Exp0+ExpNode offset=6, "b" (any):
SyntaxNode+Literal0+LiteralNode offset=6, "b" (word,negative):
SyntaxNode offset=6, ""
SyntaxNode+WordNode offset=6, "b":
SyntaxNode+Atom0 offset=6, "b":
SyntaxNode offset=6, ""
SyntaxNode offset=6, "b"
You can parse quoted strings:
parser = LogicalQueryParser.new
parser.parse('("a a" AND "b b") OR (c AND d)')
You can also parse negative conditions:
parser = LogicalQueryParser.new
parser.parse('("a a" AND NOT "b b") OR (c AND -d)')
For more information, see grammar definition.
You can use a syntax tree to compile a SQL statement for activerecord. For example:
class Doc < ActiveRecord::Base
end
LogicalQueryParser.search("a AND b", Doc.all, :c1, :c2).to_sql
# SELECT "docs".* FROM "docs"
# WHERE (("docs"."c1" LIKE '%a%' OR "docs"."c2" LIKE '%a%') AND ("docs"."c1" LIKE '%b%' OR "docs"."c2" LIKE '%b%'))
Use with associations:
class Doc < ActiveRecord::Base
has_many :tags
end
class Tag < ActiveRecord::Base
end
LogicalQueryParser.search("a AND b", Doc.all, :c1, :c2, tags: [:c3]).to_sql
# SELECT "docs".* FROM "docs"
# INNER JOIN "tags" ON "tags"."doc_id" = "docs"."id"
# WHERE ((("docs"."c1" LIKE '%a%' OR "docs"."c2" LIKE '%a%') OR "tags"."c3" LIKE '%a%') AND
# (("docs"."c1" LIKE '%b%' OR "docs"."c2" LIKE '%b%') OR "tags"."c3" LIKE '%b%'))
Bug reports and pull requests are welcome on GitHub at https://github.com/kanety/logical_query_parser.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that logical_query_parser demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.