Sha256: de918586468c8b1a2eafc58f94383186329e362e36311aca9dea7de332bc0ade

Contents?: true

Size: 728 Bytes

Versions: 10

Compression:

Stored size: 728 Bytes

Contents

require 'jdbc_common'
require 'db/postgres'

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

10 entries across 10 versions & 3 rubygems

Version Path
activerecord-jdbc-adapter-1.2.9.1 test/postgres_nonseq_pkey_test.rb
activerecord-jdbc-adapter-1.2.9 test/postgres_nonseq_pkey_test.rb
activerecord-jdbc-adapter-1.2.8 test/postgres_nonseq_pkey_test.rb
tgbyte-activerecord-jdbc-adapter-1.2.2.5 test/postgres_nonseq_pkey_test.rb
tgbyte-activerecord-jdbc-adapter-1.2.2.4 test/postgres_nonseq_pkey_test.rb
tgbyte-activerecord-jdbc-adapter-1.2.2.3 test/postgres_nonseq_pkey_test.rb
tgbyte-activerecord-jdbc-adapter-1.2.2.2 test/postgres_nonseq_pkey_test.rb
activerecord-jdbc-adapter-1.2.2.1 test/postgres_nonseq_pkey_test.rb
activerecord-jdbc-adapter-onsite-1.2.2 test/postgres_nonseq_pkey_test.rb
activerecord-jdbc-adapter-1.2.2 test/postgres_nonseq_pkey_test.rb