Redmine 4.1.1

This commit is contained in:
Manuel Cillero 2020-11-22 21:20:06 +01:00
parent 33e7b881a5
commit 3d976f1b3b
1593 changed files with 36180 additions and 19489 deletions

View file

@ -1,5 +1,7 @@
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2006-2019 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -21,7 +23,7 @@ module Redmine
class << self
# Returns true if the database is PostgreSQL
def postgresql?
(ActiveRecord::Base.connection.adapter_name =~ /postgresql/i).present?
/postgresql/i.match?(ActiveRecord::Base.connection.adapter_name)
end
# Returns the PostgreSQL version or nil if another DBMS is used
@ -46,7 +48,7 @@ module Redmine
# Returns true if the database is MySQL
def mysql?
(ActiveRecord::Base.connection.adapter_name =~ /mysql/i).present?
/mysql/i.match?(ActiveRecord::Base.connection.adapter_name)
end
# Returns a SQL statement for case/accent (if possible) insensitive match
@ -64,6 +66,27 @@ module Redmine
end
end
# Returns a SQL statement to cast a timestamp column to a date given a time zone
# Returns nil if not implemented for the current database
def timestamp_to_date(column, time_zone)
if postgresql?
if time_zone
identifier = ActiveSupport::TimeZone.find_tzinfo(time_zone.name).identifier
"(#{column}::timestamptz AT TIME ZONE '#{identifier}')::date"
else
"#{column}::date"
end
elsif mysql?
if time_zone
user_identifier = ActiveSupport::TimeZone.find_tzinfo(time_zone.name).identifier
local_identifier = ActiveSupport::TimeZone.find_tzinfo(Time.zone.name).identifier
"DATE(CONVERT_TZ(#{column},'#{local_identifier}', '#{user_identifier}'))"
else
"DATE(#{column})"
end
end
end
# Resets database information
def reset
@postgresql_unaccent = nil