Sha256: b64f85a771f4be54d6c0cb275ab8222601bebfc3feac816ebb84dd531590ac0f

Contents?: true

Size: 973 Bytes

Versions: 1

Compression:

Stored size: 973 Bytes

Contents

require 'test/unit'
require File.dirname(__FILE__) + '../../lib/active_record/connection_adapters/mysql_adapter'
require 'jdbc_common'

class Project < ActiveRecord::Migration
  def self.up
    create_table :project, :primary_key => "project_id" do |t|
      t.string      :projectType, :limit => 31
      t.boolean     :published
      t.datetime    :created_date
      t.text        :abstract, :title
    end
  end

  def self.down
    drop_table :project
  end

end

class MysqlNonstandardPrimaryKeyTest < Test::Unit::TestCase

  def setup
    Project.up
  end

  def teardown
    Project.down
  end

  def standard_dump
    stream = StringIO.new
    ActiveRecord::SchemaDumper.ignore_tables = []
    ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
    stream.string
  end

  def test_nonstandard_primary_key
    output = standard_dump
    assert_match %r(:primary_key => "project_id"), output, "non-standard primary key not preserved"
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
saturnflyer-activerecord-jdbc-adapter-0.9.3 test/mysql_nonstandard_primary_key_test.rb