From 400d7932ebfeb2be139faa1b6f9e1cc3ac39b816 Mon Sep 17 00:00:00 2001 From: Philipp Thun Date: Wed, 21 Dec 2022 15:56:54 +0100 Subject: [PATCH] Override empty_from_sql for MySQL Specify a dummy table name for situations where no table is referenced. See MySQL 5.7 Reference Manual [1] and suggested workaround [2]. [1] https://dev.mysql.com/doc/refman/5.7/en/select.html [2] https://github.com/jeremyevans/sequel/issues/1977#issuecomment-1359631724 --- lib/cloud_controller/db.rb | 4 ++++ middleware/block_v3_only_roles.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/cloud_controller/db.rb b/lib/cloud_controller/db.rb index d4d682657b4..4f745ea18ac 100644 --- a/lib/cloud_controller/db.rb +++ b/lib/cloud_controller/db.rb @@ -133,6 +133,10 @@ def post_load(all_records) end end + def empty_from_sql + ' FROM DUAL' if self.db.database_type == :mysql + end + @unique_names_in_subquery = nil class << self diff --git a/middleware/block_v3_only_roles.rb b/middleware/block_v3_only_roles.rb index 0c0d2102cb0..7df08ac9270 100644 --- a/middleware/block_v3_only_roles.rb +++ b/middleware/block_v3_only_roles.rb @@ -36,7 +36,7 @@ def globally_authenticated? end def space_supporter_and_only_space_supporter?(current_user) - return false if VCAP::CloudController::User. + return false if VCAP::CloudController::User.db.select(1). where do Sequel.or( [