Header

  1. View current page

    RubyOnRails 2.1 - What's New!

12. 수정된 버그

수정된 버그

PostgreSQL에서 컬럼추가

PostgreSQL 데이터베이스를 쓰면서, 마이그레이션에서 기존 테이블에 컬럼을 추가할 때 버그가 있다. 예제를 보자.

File: db/migrate/002_add_cost.rb

  1. class AddCost < ActiveRecord::Migration
      def self.up
       add_column :items, :cost, :decimal, :precision => 6, :scale => 2
      end

      def self.down
       remove_column :items, :cost
      end
    end

:precision => 6, :scale => 2 옵션을 주고 컬럼을 생성할 것이다.. rake db:migrate 를 실행한다. 변경된 테이블 내역을 확인해보겠다.

Column Type Modifiers
id integer not null
desc character varying(255)  
price numeric(5,2)  
cost numeric  

"cost"컬럼이 생성되었지만 numeric타입이다. "price"와 같은 컬럼타입이라 추측할 수도 있다. 하지만 정확하게 numeric(6,2) 타입이 되어야만 한다. 이 버그는 레일스2.1에서 해결되었다. 이제 컬럼은 의도한 대로 생성될 것이다.

 

마임타입(Mime Types)

request.format 속성값으로서 심벌(symbol)을 쓸 수 없었던 버그이다. 버그는 수정되었고 아래와 같이 쓸 수 있다.

  1. request.format = :iphone
    assert_equal :iphone, request.format

 

change_column시에 버그수정

:null=>false옵션으로 생성된 컬럼을 :null=>true인자를 주고 change_column했을 때 적용되지 않던 버그가 수정되었다.

History

Last edited on 06/24/2008 21:31 by 이진석

Comments (0)

You must log in to leave a comment. Please sign in.