summaryrefslogtreecommitdiff
path: root/lib/gitlab/database.rb
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2016-06-18 10:55:45 -0700
committerStan Hu <stanhu@gmail.com>2016-06-18 13:07:38 -0700
commit7c9eba891963451a1feb2e5bbef90fdcac1496ff (patch)
tree51692ed3b138406a8d0bc740eb259076e91e4361 /lib/gitlab/database.rb
parent00906b5bb6cde8cb60281109060a519a54000c61 (diff)
downloadgitlab-ce-7c9eba891963451a1feb2e5bbef90fdcac1496ff.tar.gz
Fix RangeError exceptions when referring to issues or merge requests outside of max database values
When using #XYZ in Markdown text, if XYZ exceeds the maximum value of a signed 32-bit integer, we get an exception when the Markdown render attempts to run `where(iids: XYZ)`. Introduce a method that will throw out out-of-bounds values. Closes #18777
Diffstat (limited to 'lib/gitlab/database.rb')
-rw-r--r--lib/gitlab/database.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/gitlab/database.rb b/lib/gitlab/database.rb
index d76ecb54017..078609c86f1 100644
--- a/lib/gitlab/database.rb
+++ b/lib/gitlab/database.rb
@@ -1,5 +1,10 @@
module Gitlab
module Database
+ # The max value of INTEGER type is the same between MySQL and PostgreSQL:
+ # https://www.postgresql.org/docs/9.2/static/datatype-numeric.html
+ # http://dev.mysql.com/doc/refman/5.7/en/integer-types.html
+ MAX_INT_VALUE = 2147483647
+
def self.adapter_name
connection.adapter_name
end