# PostgreSQL and unit tests

**URL:** <https://www.ruby-forum.com/t/postgresql-and-unit-tests/93431>\
**Category:** Rails\
**Created:** [April 3, 2006, 1:20am UTC](https://www.ruby-forum.com/t/postgresql-and-unit-tests/93431 "2006-04-03T01:20:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pergesu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pergesu](https://www.ruby-forum.com/u/pergesu)\
**Post date:** [April 3, 2006, 1:20am UTC](https://www.ruby-forum.com/t/postgresql-and-unit-tests/93431/1 "2006-04-03T01:20:32Z")

</div>

After upgrading to 1.1, I can’t run any unit tests. Apparently when I  
run rake test\_units, it uses a migration to set up the database.  
Unfortunately when it runs the migration, it’s adding not null  
constraints to every field, even though I haven’t got that set up.  
I’m using the ruby-postgres (0.7.1.2005.12.21) adapter with PostgreSQL  
8.1.0.

I’m getting closer to switching over to MySQL, even though I prefer  
PostgreSQL in general, as there are lots of little gotchas that get in  
the way of development. I always question whether the rails code base  
actually gets tested against postgres.

Pat

---

<div class="post-metadata">

**Author:** ![pergesu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pergesu](https://www.ruby-forum.com/u/pergesu)\
**Post date:** [April 3, 2006, 1:35am UTC](https://www.ruby-forum.com/t/postgresql-and-unit-tests/93431/2 "2006-04-03T01:35:35Z")

</div>

On Sun, 2006-04-02 at 16:19 -0700, Pat M. wrote:

> actually gets tested against postgres.

* * *

I’m using gem…

postgres (0.7.1)  
The extension library to access a PostgreSQL database from Ruby.

rails (1.1.0, 1.0.0)  
Web-application framework with template engine, control-flow layer,  
and ORM.

rake (0.7.0, 0.6.2)  
Ruby based make-like utility.

# rpm -q postgresql

postgresql-7.4.8-1.RHEL4.1

and I just tested this and I didn’t have a problem with NOT NULL  
migrations…they turned out just as defined.

Craig

---

<div class="post-metadata">

**Author:** ![pergesu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pergesu](https://www.ruby-forum.com/u/pergesu)\
**Post date:** [April 3, 2006, 2:07am UTC](https://www.ruby-forum.com/t/postgresql-and-unit-tests/93431/3 "2006-04-03T02:07:41Z")

</div>

Pat M. wrote:

> After upgrading to 1.1, I can’t run any unit tests. Apparently when I  
> run rake test\_units, it uses a migration to set up the database.  
> Unfortunately when it runs the migration, it’s adding not null  
> constraints to every field, even though I haven’t got that set up.  
> I’m using the ruby-postgres (0.7.1.2005.12.21) adapter with PostgreSQL  
> 8.1.0.
> 
> I’m getting closer to switching over to MySQL, even though I prefer  
> PostgreSQL in general, as there are lots of little gotchas that get in  
> the way of development. I always question whether the rails code base  
> actually gets tested against postgres.
> 
> Pat

Please try using ‘postgres’ gem instead of ‘ruby-postgres’ gem and let  
us know what happens.

There are 3 different postgres drivers for Ruby, we should probably  
bless one of them as the preferred driver for rails-1.1 and beyond.

---

<div class="post-metadata">

**Author:** ![pergesu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pergesu](https://www.ruby-forum.com/u/pergesu)\
**Post date:** [April 3, 2006, 7:54am UTC](https://www.ruby-forum.com/t/postgresql-and-unit-tests/93431/4 "2006-04-03T07:54:54Z")

</div>

Use the latest release version of ruby-postgres, no the latest build.

I attempted to ‘update’ once before and ran into the same problem.

–  
– Tom M.

---

<div class="post-metadata">

**Author:** ![pergesu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pergesu](https://www.ruby-forum.com/u/pergesu)\
**Post date:** [April 3, 2006, 8:01am UTC](https://www.ruby-forum.com/t/postgresql-and-unit-tests/93431/5 "2006-04-03T08:01:00Z")

</div>

On Sun, 2006-04-02 at 22:52 -0700, Tom M. wrote:

> Use the latest release version of ruby-postgres, no the latest build.
> 
> I attempted to ‘update’ once before and ran into the same problem.

* * *

I guess I was lucky to have chosen the postgres gem and thus was spared  
but I have been having a problem now of new rows created in the  
schema\_info table rather than updating the 1 row. I do recall someone  
asking about that in the past so I know it’s in the archives but if it’s  
an easy answer, perhaps someone wants to save me the trouble of  
searching the archives.

Craig

---

<div class="post-metadata">

**Author:** ![pergesu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pergesu](https://www.ruby-forum.com/u/pergesu)\
**Post date:** [April 3, 2006, 2:39am UTC](https://www.ruby-forum.com/t/postgresql-and-unit-tests/93431/6 "2006-04-03T02:39:02Z")

</div>

On 4/2/06, John S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > the way of development. I always question whether the rails code base  
> > –  
> > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

Okay some of my gems were messed up so it took a while, but the tests  
work using ‘postgres’ instead.

As for the three different drivers…it’s just really confusing, to  
tell you the truth. Periodically I post to the list asking which one  
to use, but there’s never a consensus it seems.

Thanks for the help.

Pat
