Method: Redmine::Database.postgresql_unaccent?

Defined in:
lib/redmine/database.rb

.postgresql_unaccent?Boolean

Returns true if the database is a PostgreSQL >=9.0 database with the unaccent extension installed

Returns:

  • (Boolean)


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/redmine/database.rb', line 40

def postgresql_unaccent?
  if postgresql?
    return @postgresql_unaccent unless @postgresql_unaccent.nil?

    begin
      sql =
        "SELECT name FROM pg_available_extensions " \
          "WHERE installed_version IS NOT NULL and name = 'unaccent'"
      @postgresql_unaccent =
        postgresql_version >= 90000 &&
          ActiveRecord::Base.connection.select_value(sql).present?
    rescue
      false
    end
  else
    false
  end
end