Sha256: 5cbea48ca6517036974cae685dfb7cc1e4ef6b350cde2734577e6fa12af564cf

Contents?: true

Size: 1.22 KB

Versions: 6

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

require "cases/helper"
require "support/schema_dumping_helper"

class PostgresqlFullTextTest < ActiveRecord::PostgreSQLTestCase
  include SchemaDumpingHelper
  class Tsvector < ActiveRecord::Base; end

  setup do
    @connection = ActiveRecord::Base.connection
    @connection.create_table("tsvectors") do |t|
      t.tsvector "text_vector"
    end
  end

  teardown do
    @connection.drop_table "tsvectors", if_exists: true
  end

  def test_tsvector_column
    column = Tsvector.columns_hash["text_vector"]
    assert_equal :tsvector, column.type
    assert_equal "tsvector", column.sql_type
    assert_not_predicate column, :array?

    type = Tsvector.type_for_attribute("text_vector")
    assert_not_predicate type, :binary?
  end

  def test_update_tsvector
    Tsvector.create text_vector: "'text' 'vector'"
    tsvector = Tsvector.first
    assert_equal "'text' 'vector'", tsvector.text_vector

    tsvector.text_vector = "'new' 'text' 'vector'"
    tsvector.save!
    assert tsvector.reload
    assert_equal "'new' 'text' 'vector'", tsvector.text_vector
  end

  def test_schema_dump_with_shorthand
    output = dump_table_schema("tsvectors")
    assert_match %r{t\.tsvector "text_vector"}, output
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ibm_db-5.5.1 test/cases/adapters/postgresql/full_text_test.rb
ibm_db-5.5.0 test/cases/adapters/postgresql/full_text_test.rb
ibm_db-5.4.1 test/cases/adapters/postgresql/full_text_test.rb
ibm_db-5.4.0 test/cases/adapters/postgresql/full_text_test.rb
ibm_db-5.3.2 test/cases/adapters/postgresql/full_text_test.rb
ibm_db-5.3.1 test/cases/adapters/postgresql/full_text_test.rb