Rake test:units fails on Postgresql due to nil

Following the directions in:

http://www.xml.com/pub/a/2006/04/19/rest-on-rails.html?page=2

I get through the:

rake db:migrate

With the tables created properly but then when I run the:

rake test:units

I get a failure:

ActiveRecord::StatementInvalid: RuntimeError: ERROR C23502 Mnull
value in column “title” violates not-null constraint FexecMain.c
L1750 RExecConstraints: INSERT INTO books (“id”) VALUES (2)

My only departure from the directions is to use postgresql rather than
mysql as the database adapter.

I’m not sure which driver you’re using, but it
sounds like you’re using this one:
Snapshot version ruby-postgres-20051221.tar.gz (2005/12/21)

If so, you should use this one instead:

Release version ruby-postgres-0.7.1.tar.gz(2003/01/06)

Both are available here:

http://ruby.scripting.ca/postgres/

And a discussion on this topic can be found here:

http://lists.rubyonrails.org/pipermail/rails/2006-March/022710.html


– Tom M.

No joy.

I downloaded, zxvf’d it, ruby extconf.rb’ed it, make’ed it and make
install’ed it

Deleted the tables and reran rake db:migrate

Then on make test:units

(in /var/www/rails/library)
NOTICE: CREATE TABLE will create implicit sequence “books_id_seq” for
serial column “books.id”
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
“books_pkey” for table “books”
/usr/bin/ruby -Ilib:test
“/usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake/rake_test_loader.rb”
“test/unit/book_test.rb”
Loaded suite
/usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake/rake_test_loader
Started
EWARNING: there is no transaction in progress
E
Finished in 0.027749 seconds.

  1. Error:
    test_truth(BookTest):
    ActiveRecord::StatementInvalid: PGError: ERROR: null value in column
    “title” violates not-null constraint
    : INSERT INTO books (“id”) VALUES (2)
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/abstract_adapter.rb:120:in
    `log’

Tom M. wrote:

I’m not sure which driver you’re using, but it
sounds like you’re using this one:
Snapshot version ruby-postgres-20051221.tar.gz (2005/12/21)

If so, you should use this one instead:

Release version ruby-postgres-0.7.1.tar.gz(2003/01/06)

Both are available here:

http://ruby.scripting.ca/postgres/

And a discussion on this topic can be found here:

http://lists.rubyonrails.org/pipermail/rails/2006-March/022710.html

Can we see that migration and fixture?

– -- Tom M.