# Rake test:units fails on Postgresql due to nil

**URL:** <https://www.ruby-forum.com/t/rake-test-units-fails-on-postgresql-due-to-nil/58713>\
**Category:** Rails\
**Created:** [April 25, 2006, 6:00am UTC](https://www.ruby-forum.com/t/rake-test-units-fails-on-postgresql-due-to-nil/58713 "2006-04-25T06:00:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [April 25, 2006, 6:00am UTC](https://www.ruby-forum.com/t/rake-test-units-fails-on-postgresql-due-to-nil/58713/1 "2006-04-25T06:00:57Z")

</div>

Following the directions in:

[http://www.xml.com/pub/a/2006/04/19/rest-on-rails.html?page=2](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.

---

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [April 25, 2006, 9:55am UTC](https://www.ruby-forum.com/t/rake-test-units-fails-on-postgresql-due-to-nil/58713/2 "2006-04-25T09:55:26Z")

</div>

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/](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](http://lists.rubyonrails.org/pipermail/rails/2006-March/022710.html)

–  
– Tom M.

---

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [April 26, 2006, 1:38am UTC](https://www.ruby-forum.com/t/rake-test-units-fails-on-postgresql-due-to-nil/58713/3 "2006-04-26T01:38:52Z")

</div>

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/](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](http://lists.rubyonrails.org/pipermail/rails/2006-March/022710.html)

---

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [April 26, 2006, 3:01am UTC](https://www.ruby-forum.com/t/rake-test-units-fails-on-postgresql-due-to-nil/58713/4 "2006-04-26T03:01:12Z")

</div>

Can we see that migration and fixture?

– -- Tom M.
