Skip to content

Commit

Permalink
fix nodes when call computed_attributes and pass collection class as …
Browse files Browse the repository at this point in the history
…filter condition
  • Loading branch information
diegosenarruzza committed Nov 5, 2020
1 parent 208e5f3 commit e2a930e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/rasti/db/nql/nodes/binary_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ def dependency_tables
values.flat_map(&:dependency_tables)
end

def computed_attributes
left.computed_attributes | right.computed_attributes
def computed_attributes(collection_class)
left.computed_attributes(collection_class) | right.computed_attributes(collection_class)
end

def values
Expand Down
4 changes: 2 additions & 2 deletions lib/rasti/db/nql/nodes/comparisons/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ def dependency_tables
attribute.tables.empty? ? [] : [attribute.tables.join('.')]
end

def computed_attributes
attribute.computed_attributes
def computed_attributes(collection_class)
attribute.computed_attributes(collection_class)
end

end
Expand Down
4 changes: 2 additions & 2 deletions lib/rasti/db/nql/nodes/parenthesis_sentence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ def dependency_tables
sentence.dependency_tables
end

def computed_attributes
sentence.computed_attributes
def computed_attributes(collection_class)
sentence.computed_attributes(collection_class)
end

def filter_condition(collection_class)
Expand Down
4 changes: 2 additions & 2 deletions lib/rasti/db/nql/nodes/sentence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ def dependency_tables
proposition.dependency_tables
end

def computed_attributes
proposition.computed_attributes
def computed_attributes(collection_class)
proposition.computed_attributes collection_class
end

def filter_condition(collection_class)
Expand Down
2 changes: 1 addition & 1 deletion lib/rasti/db/query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def nql(filter_expression)

raise NQL::InvalidExpressionError.new(filter_expression) if sentence.nil?

ds = sentence.computed_attributes.inject(dataset) do |ds, name|
ds = sentence.computed_attributes(collection_class).inject(dataset) do |ds, name|
collection_class.computed_attributes[name].apply_join ds
end
query = build_query dataset: ds
Expand Down

0 comments on commit e2a930e

Please sign in to comment.