Sha256: e28d8c89e21459d09b2440114506f6031dc3b4f15a9fbeccebe977548c7d991b

Contents?: true

Size: 706 Bytes

Versions: 1

Compression:

Stored size: 706 Bytes

Contents

require 'jdbc_common'

class CreateUrls < ActiveRecord::Migration
  def self.up
    create_table 'urls', :id => false do |t|
      t.text :uhash, :null => false
      t.text :url,  :null => false
    end
    execute "ALTER TABLE urls ADD PRIMARY KEY (uhash)"
  end
  def self.down
    drop_table 'urls'
  end
end

class Url < ActiveRecord::Base
  self.primary_key = :uhash
  #Shouldn't be needed: set_sequence_name nil
end

class PostgresNonSeqPKey < Test::Unit::TestCase
  def setup
    CreateUrls.up
  end

  def teardown
    CreateUrls.down
  end

  def test_create
    url = Url.create! do |u|
      u.uhash = 'uhash'
      u.url = 'http://url'
    end
    assert_equal( 'uhash', url.uhash )
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activerecord-jdbc-adapter-1.2.5 test/postgres_nonseq_pkey_test.rb