Forum: Ruby on Rails rake test:units fails on Postgresql due to nil

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
576dc5912e2f35ddb4c9acc8a5e7969f?d=identicon&s=25 James Bowery (jabowery)
on 2006-04-25 06:00
Following the directions in:

http://www.xml.com/pub/a/2006/04/19/rest-on-rails....

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.
59de94a56fd2c198f33d9515d1c05961?d=identicon&s=25 Tom Mornini (Guest)
on 2006-04-25 09:55
(Received via mailing list)
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-...

--
-- Tom Mornini
576dc5912e2f35ddb4c9acc8a5e7969f?d=identicon&s=25 James Bowery (jabowery)
on 2006-04-26 01:38
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 Mornini 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-...
>
59de94a56fd2c198f33d9515d1c05961?d=identicon&s=25 Tom Mornini (Guest)
on 2006-04-26 03:01
(Received via mailing list)
Can we see that migration and fixture?

-- -- Tom Mornini
This topic is locked and can not be replied to.