Skip to content

Commit c0af6ac

Browse files
committed
chore: fix subquery for mysql
1 parent efce423 commit c0af6ac

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/pact_broker/pacts/repository.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def delete params
104104
.consumer_name_like(params.consumer_name)
105105
.provider_name_like(params.provider_name)
106106
.consumer_version_number_like(params.consumer_version_number)
107-
.select_for_subquery(Sequel[:pact_publications][:id])
107+
.select_for_subquery(Sequel[:pact_publications][:id].as(:id))
108108
unscoped(PactPublication).where(id: id).delete
109109
end
110110

lib/pact_broker/repositories/helpers.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ def select_all_qualified
4444
end
4545

4646
def select_for_subquery column
47-
if mysql? #stoopid mysql doesn't allow subqueries
48-
select(column).collect{ | it | it[column] }
47+
if mysql? #stoopid mysql doesn't allow you to modify datasets with subqueries
48+
column_name = column.respond_to?(:alias) ? column.alias : column
49+
select(column).collect{ | it | it[column_name] }
4950
else
5051
select(column)
5152
end

0 commit comments

Comments
 (0)