summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPaco Guzman <pacoguzmanp@gmail.com>2016-09-27 17:13:20 +0200
committerPaco Guzman <pacoguzmanp@gmail.com>2016-09-28 09:08:28 +0200
commitf4a84f504f2119a32a6c8909dc72680a191d7174 (patch)
tree05566ac2864238eb4edb091a9aad88839ba840fc /lib
parent684baf7e7e8f7263bba6cccb7457bbc242135484 (diff)
downloadgitlab-ce-f4a84f504f2119a32a6c8909dc72680a191d7174.tar.gz
Avoid database queries on Banzai::ReferenceParser::BaseParser for nodes without references22681-avoid-empty-queries-on-reference-parsers
Diffstat (limited to 'lib')
-rw-r--r--lib/banzai/reference_parser/base_parser.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/banzai/reference_parser/base_parser.rb b/lib/banzai/reference_parser/base_parser.rb
index e8e03e4a98f..f5d110e987b 100644
--- a/lib/banzai/reference_parser/base_parser.rb
+++ b/lib/banzai/reference_parser/base_parser.rb
@@ -79,7 +79,11 @@ module Banzai
def referenced_by(nodes)
ids = unique_attribute_values(nodes, self.class.data_attribute)
- references_relation.where(id: ids)
+ if ids.empty?
+ references_relation.none
+ else
+ references_relation.where(id: ids)
+ end
end
# Returns the ActiveRecord::Relation to use for querying references in the