Skip to content

Commit

Permalink
fix(matrix): correct logic for selecting matrix rows on MySQL
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Feb 5, 2018
1 parent 8f6d2ba commit 06f6dd4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
14 changes: 0 additions & 14 deletions lib/pact_broker/matrix/latest_row.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,6 @@ module Matrix
# Latest pact revision for each consumer version => latest verification for each provider version
class LatestRow < Row
set_dataset(:latest_matrix_for_consumer_version_and_provider_version)

# For some reason, with MySQL, the success column value
# comes back as an integer rather than a boolean
# for the latest_matrix view (but not the matrix view!)
# Maybe something to do with the union?
# Haven't investigated as this is an easy enough fix.
def success
value = super
value.nil? ? nil : value == true || value == 1
end

def values
super.merge(success: success)
end
end
end
end
2 changes: 1 addition & 1 deletion lib/pact_broker/matrix/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def find_for_consumer_and_provider pacticipant_1_name, pacticipant_2_name
end

def find_compatible_pacticipant_versions selectors
find(selectors, latestby: 'cvpv').select{|line| line[:success] }
find(selectors, latestby: 'cvpv').select{|line| line.success }
end

def query_matrix selectors, options
Expand Down
8 changes: 8 additions & 0 deletions lib/pact_broker/matrix/row.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,14 @@ def success
def values
super.merge(success: success)
end

# Need to overwrite eql? from lib/sequel/model/base.rb
# because it uses @values instead of self.values
# so the success boolean/integer problem mentioned above
# screws things up
def eql?(obj)
(obj.class == model) && (obj.values == values)
end
end
end
end

0 comments on commit 06f6dd4

Please sign in to comment.