Skip to content

Commit

Permalink
bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Txus committed Oct 10, 2022
1 parent 6b679be commit 0847f3b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
fql (0.2.3)
fql (0.2.4)
activerecord (~> 6.0)
i18n (~> 1.8)
sorbet-rails (~> 0.7.3)
Expand Down
24 changes: 12 additions & 12 deletions lib/fql/serde/json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,29 +90,29 @@ def parse_expression(expr)
parse_expression(expr[:rhs]).map do |rhs|
lhs = T.cast(lhs, Query::DSL::BoolExpr)
rhs = T.cast(rhs, Query::DSL::BoolExpr)
Query::DSL::And.new(lhs: lhs, rhs: rhs, metadata: expr[:metadata])
Query::DSL::And.new(lhs: lhs, rhs: rhs, metadata: expr.fetch(:metadata, {}))
end
end
when "eq"
parse_expression(expr[:lhs]).bind do |lhs|
parse_expression(expr[:rhs]).map do |rhs|
lhs = T.cast(lhs, Query::DSL::ValueExpr)
rhs = T.cast(rhs, T.nilable(Query::DSL::ValueExpr))
Query::DSL::Eq.new(lhs: lhs, rhs: rhs, metadata: expr[:metadata])
Query::DSL::Eq.new(lhs: lhs, rhs: rhs, metadata: expr.fetch(:metadata, {}))
end
end
when "or"
parse_expression(expr[:lhs]).bind do |lhs|
parse_expression(expr[:rhs]).map do |rhs|
lhs = T.cast(lhs, Query::DSL::BoolExpr)
rhs = T.cast(rhs, Query::DSL::BoolExpr)
Query::DSL::Or.new(lhs: lhs, rhs: rhs, metadata: expr[:metadata])
Query::DSL::Or.new(lhs: lhs, rhs: rhs, metadata: expr.fetch(:metadata, {}))
end
end
when "not"
parse_expression(expr[:expr]).map do |expression|
expression = T.cast(expression, Query::DSL::BoolExpr)
Query::DSL::Not.new(expr: expression, metadata: expr[:metadata])
Query::DSL::Not.new(expr: expression, metadata: expr.fetch(:metadata, {}))
end
when "gt", "gte", "lt", "lte"
parse_expression(expr[:lhs]).bind do |lhs|
Expand All @@ -128,18 +128,18 @@ def parse_expression(expr)
Query::DSL::Lt
when "lte"
Query::DSL::Lte
end).new(lhs: lhs, rhs: rhs, metadata: expr[:metadata])
end).new(lhs: lhs, rhs: rhs, metadata: expr.fetch(:metadata, {}))
end
end
when "rel"
Outcome.ok(Query::DSL::Rel.new(name: expr[:name].map(&:to_sym), metadata: expr[:metadata]))
Outcome.ok(Query::DSL::Rel.new(name: expr[:name].map(&:to_sym), metadata: expr.fetch(:metadata, {})))
when "attr"
parse_expression(expr[:target]).map do |target|
target = T.cast(target, Query::DSL::Rel)
Query::DSL::Attr.new(target: target, name: expr[:name].to_sym, metadata: expr[:metadata])
Query::DSL::Attr.new(target: target, name: expr[:name].to_sym, metadata: expr.fetch(:metadata, {}))
end
when "var"
Outcome.ok(Query::DSL::Var.new(name: expr[:name].to_sym, metadata: expr[:metadata]))
Outcome.ok(Query::DSL::Var.new(name: expr[:name].to_sym, metadata: expr.fetch(:metadata, {})))
when "call"
args = expr[:arguments].map { |arg| parse_expression(arg) }
errors = args.select(&:error?).map do |errored|
Expand All @@ -149,22 +149,22 @@ def parse_expression(expr)
Outcome.error(errors.join(", "))
else
parsed = args.map(&:value)
Outcome.ok(Query::DSL::Call.new(name: expr[:name].to_sym, arguments: parsed, metadata: expr[:metadata]))
Outcome.ok(Query::DSL::Call.new(name: expr[:name].to_sym, arguments: parsed, metadata: expr.fetch(:metadata, {})))
end
when "one_of"
parse_expression(expr[:member]).map do |member|
member = T.cast(member, Query::DSL::ValueExpr)
Query::DSL::OneOf.new(member: member, set: expr[:set], metadata: expr[:metadata])
Query::DSL::OneOf.new(member: member, set: expr[:set], metadata: expr.fetch(:metadata, {}))
end
when "contains"
parse_expression(expr[:lhs]).map do |lhs|
lhs = T.cast(lhs, Query::DSL::ValueExpr)
Query::DSL::Contains.new(lhs: lhs, rhs: expr[:rhs], metadata: expr[:metadata])
Query::DSL::Contains.new(lhs: lhs, rhs: expr[:rhs], metadata: expr.fetch(:metadata, {}))
end
when "matches_regex"
parse_expression(expr[:lhs]).map do |lhs|
lhs = T.cast(lhs, Query::DSL::ValueExpr)
Query::DSL::MatchesRegex.new(lhs: lhs, rhs: expr[:rhs], metadata: expr[:metadata])
Query::DSL::MatchesRegex.new(lhs: lhs, rhs: expr[:rhs], metadata: expr.fetch(:metadata, {}))
end
else
Outcome.error("unrecognized op '#{expr[:op]}'")
Expand Down
2 changes: 1 addition & 1 deletion lib/fql/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: false
module FQL
VERSION = "0.2.3".freeze
VERSION = "0.2.4".freeze
end

0 comments on commit 0847f3b

Please sign in to comment.