Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-01 00:05:24 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-01 00:05:24 +0300
commitc741c26fa0743e76c9331aa214ebe16559f1d2a6 (patch)
tree183d27ae527c89173872b4f9702bb64b3ac386a4 /lib
parente9fe125578e745a7b18bed97eb3653bf5c0f4035 (diff)
Add latest changes from gitlab-org/gitlab@12-7-stable-ee
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/database/grant.rb11
1 files changed, 3 insertions, 8 deletions
diff --git a/lib/gitlab/database/grant.rb b/lib/gitlab/database/grant.rb
index 1f47f320a29..7774dd9fffe 100644
--- a/lib/gitlab/database/grant.rb
+++ b/lib/gitlab/database/grant.rb
@@ -3,23 +3,18 @@
module Gitlab
module Database
# Model that can be used for querying permissions of a SQL user.
- class Grant < ActiveRecord::Base
- include FromUnion
-
- self.table_name = 'information_schema.role_table_grants'
-
+ class Grant
# Returns true if the current user can create and execute triggers on the
# given table.
def self.create_and_execute_trigger?(table)
# We _must not_ use quote_table_name as this will produce double
# quotes on PostgreSQL and for "has_table_privilege" we need single
# quotes.
+ connection = ActiveRecord::Base.connection
quoted_table = connection.quote(table)
begin
- from(nil)
- .pluck(Arel.sql("has_table_privilege(#{quoted_table}, 'TRIGGER')"))
- .first
+ connection.select_one("SELECT has_table_privilege(#{quoted_table}, 'TRIGGER')").present?
rescue ActiveRecord::StatementInvalid
# This error is raised when using a non-existing table name. In this
# case we just want to return false as a user technically can't