【Ruby】Ruby on Rails Part3at PHP
【Ruby】Ruby on Rails Part3 - 暇つぶし2ch170:nobodyさん
07/04/05 21:26:04
>>168の例で
t.column :name, :string, :default => 'No Name'
としたバージョンを作ってみた。

$ ./script/runner 'p Animal.new.attributes'
{"name"=>"No Name", "leg"=>4}

sqlite> .dump 'animals'
BEGIN TRANSACTION;
CREATE TABLE animals ("id" INTEGER PRIMARY KEY NOT NULL, "name" varchar(255) DEFAULT 'No Name', "leg" integer DEFAULT 4);
COMMIT;

となったぜ。DB依存なんだろうか。

$ sqlite3 -version
3.3.8
$ rails -v
Rails 1.2.3
$ ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-darwin]
$ uname -v
Darwin Kernel Version 8.9.1: Thu Feb 22 20:55:00 PST 2007; root:xnu-792.18.15~1/RELEASE_I386

AR-1.15.3/lib/active_record/connection_adapters/mysql_adapter.rb
にこんなコメントがあるんだけど英文の意味がよーわからんです。
# MySQL misreports NOT NULL column default when none is given.
# We can't detect this for columns which may have a legitimate ''
# default (string, text, binary) but we can for others (integer,
# datetime, boolean, and the rest).
#
# Test whether the column has default '', is not null, and is not
# a type allowing default ''.



次ページ
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch