Sha256: 54f671ec1830a175ed050d5bcecefe76c4139feae2f64a825e0e6755fed958d2

Contents?: true

Size: 1.21 KB

Versions: 8

Compression:

Stored size: 1.21 KB

Contents

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

class PostgresqlLtreeTest < ActiveRecord::PostgreSQLTestCase
  include SchemaDumpingHelper
  class Ltree < ActiveRecord::Base
    self.table_name = 'ltrees'
  end

  def setup
    @connection = ActiveRecord::Base.connection

    enable_extension!('ltree', @connection)

    @connection.transaction do
      @connection.create_table('ltrees') do |t|
        t.ltree 'path'
      end
    end
  rescue ActiveRecord::StatementInvalid
    skip "do not test on PG without ltree"
  end

  teardown do
    @connection.drop_table 'ltrees', if_exists: true
  end

  def test_column
    column = Ltree.columns_hash['path']
    assert_equal :ltree, column.type
    assert_equal "ltree", column.sql_type
    assert_not column.array?

    type = Ltree.type_for_attribute('path')
    assert_not type.binary?
  end

  def test_write
    ltree = Ltree.new(path: '1.2.3.4')
    assert ltree.save!
  end

  def test_select
    @connection.execute "insert into ltrees (path) VALUES ('1.2.3')"
    ltree = Ltree.first
    assert_equal '1.2.3', ltree.path
  end

  def test_schema_dump_with_shorthand
    output = dump_table_schema("ltrees")
    assert_match %r[t\.ltree "path"], output
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ibm_db-5.2.0 test/cases/adapters/postgresql/ltree_test.rb
ibm_db-5.1.0 test/cases/adapters/postgresql/ltree_test.rb
ibm_db-5.0.5 test/cases/adapters/postgresql/ltree_test.rb
ibm_db-5.0.4 test/cases/adapters/postgresql/ltree_test.rb
ibm_db-5.0.3 test/cases/adapters/postgresql/ltree_test.rb
ibm_db-5.0.2 test/cases/adapters/postgresql/ltree_test.rb
ibm_db-4.0.0-x86-mingw32 test/cases/adapters/postgresql/ltree_test.rb
ibm_db-4.0.0 test/cases/adapters/postgresql/ltree_test.rb