Sha256: b034b4d50b50df94e4afd6a0d92070559a75f911b89555d084615b52adbd1360

Contents?: true

Size: 834 Bytes

Versions: 19

Compression:

Stored size: 834 Bytes

Contents

module PgSearch
  class Normalizer
    def initialize(config)
      @config = config
    end

    def add_normalization(sql_expression)
      return sql_expression unless config.ignore.include?(:accents)

      if config.postgresql_version < 90000
        raise PgSearch::NotSupportedForPostgresqlVersion.new(<<-MESSAGE.strip_heredoc)
          Sorry, {:ignoring => :accents} only works in PostgreSQL 9.0 and above.
          #{config.inspect}
        MESSAGE
      end

      sql_node = case sql_expression
                 when Arel::Nodes::Node
                   sql_expression
                 else
                   Arel.sql(sql_expression)
                 end

      Arel::Nodes::NamedFunction.new(
        PgSearch.unaccent_function,
        [sql_node]
      ).to_sql
    end

    private

    attr_reader :config
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
pg_search-1.0.4 lib/pg_search/normalizer.rb
pg_search-1.0.3 lib/pg_search/normalizer.rb
pg_search-1.0.2 lib/pg_search/normalizer.rb
pg_search-1.0.1 lib/pg_search/normalizer.rb
pg_search-1.0.0 lib/pg_search/normalizer.rb
pg_search-0.7.9 lib/pg_search/normalizer.rb
pg_search-0.7.8 lib/pg_search/normalizer.rb
pg_search-0.7.7 lib/pg_search/normalizer.rb
pg_search-0.7.6 lib/pg_search/normalizer.rb
pg_search-0.7.5 lib/pg_search/normalizer.rb
pg_search-0.7.4 lib/pg_search/normalizer.rb
pg_search-0.7.3 lib/pg_search/normalizer.rb
pg_search-0.7.2 lib/pg_search/normalizer.rb
pg_search-0.7.1 lib/pg_search/normalizer.rb
pg_search-0.7.0 lib/pg_search/normalizer.rb
pg_search-0.6.4 lib/pg_search/normalizer.rb
pg_search-0.6.3 lib/pg_search/normalizer.rb
pg_search-0.6.2 lib/pg_search/normalizer.rb
pg_search-0.6.1 lib/pg_search/normalizer.rb