Skip to content

Commit 06f6dd4

Browse files
committed
fix(matrix): correct logic for selecting matrix rows on MySQL
1 parent 8f6d2ba commit 06f6dd4

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

lib/pact_broker/matrix/latest_row.rb

-14
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,6 @@ module Matrix
55
# Latest pact revision for each consumer version => latest verification for each provider version
66
class LatestRow < Row
77
set_dataset(:latest_matrix_for_consumer_version_and_provider_version)
8-
9-
# For some reason, with MySQL, the success column value
10-
# comes back as an integer rather than a boolean
11-
# for the latest_matrix view (but not the matrix view!)
12-
# Maybe something to do with the union?
13-
# Haven't investigated as this is an easy enough fix.
14-
def success
15-
value = super
16-
value.nil? ? nil : value == true || value == 1
17-
end
18-
19-
def values
20-
super.merge(success: success)
21-
end
228
end
239
end
2410
end

lib/pact_broker/matrix/repository.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def find_for_consumer_and_provider pacticipant_1_name, pacticipant_2_name
6161
end
6262

6363
def find_compatible_pacticipant_versions selectors
64-
find(selectors, latestby: 'cvpv').select{|line| line[:success] }
64+
find(selectors, latestby: 'cvpv').select{|line| line.success }
6565
end
6666

6767
def query_matrix selectors, options

lib/pact_broker/matrix/row.rb

+8
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,14 @@ def success
209209
def values
210210
super.merge(success: success)
211211
end
212+
213+
# Need to overwrite eql? from lib/sequel/model/base.rb
214+
# because it uses @values instead of self.values
215+
# so the success boolean/integer problem mentioned above
216+
# screws things up
217+
def eql?(obj)
218+
(obj.class == model) && (obj.values == values)
219+
end
212220
end
213221
end
214222
end

0 commit comments

Comments
 (0)