[SERIOUS BUG?] ActiveRecord 1.1.0 and PostgreSQL

To reproduce:

1. Create a postgresql table with a varchar primary key.
2. Specify a new key value and try to save the new record.

ActiveRecord will insert the record, and then immediately bomb with an error when it tries to query a non-existent sequence table. This error causes the inserted record to get rolled back.

Looks like ActiveRecord assumes that all primary keys have a sequence table in postgresql.

Am I forgetting to do something or is this a major bug in ActiveRecord?

J. D. wrote:

To reproduce:

1. Create a postgresql table with a varchar primary key.
2. Specify a new key value and try to save the new record.

ActiveRecord will insert the record, and then immediately bomb with an error when it tries to query a non-existent sequence table. This error causes the inserted record to get rolled back.

Looks like ActiveRecord assumes that all primary keys have a sequence table in postgresql.

Am I forgetting to do something or is this a major bug in ActiveRecord?

Someone reading this message over my shoulder just asked me,
'who is "reproduce"?'

LOL

Hi J. D.,

···

On Sat, 11 Dec 2004 11:27:24 +0900, J. D. <jd@nospam.com> wrote:

Looks like ActiveRecord assumes that all primary keys have a sequence
table in postgresql.

Am I forgetting to do something or is this a major bug in ActiveRecord?

It's not a bug, it's a constraint that Active Record puts on your
schema so that it can guess the proper sequence name. For rationale,
see Ruby on Rails — A web-app framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern..

Sam

Sam Stephenson wrote:

Hi J. D.,

Looks like ActiveRecord assumes that all primary keys have a sequence
table in postgresql.

Am I forgetting to do something or is this a major bug in ActiveRecord?

It's not a bug, it's a constraint that Active Record puts on your
schema so that it can guess the proper sequence name. For rationale,
see Ruby on Rails — A web-app framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern..

Sam

I finally tracked down a bug report and a patch already in CVS. I tried the patch shown in ticket 230 and it fixed the problem.

http://dev.rubyonrails.org/trac.cgi/ticket/230
http://dev.rubyonrails.org/trac.cgi/ticket/117

Now I have to fix the loss of my credibility for recommending ActiveRecord 1.1.0 as being production-ready. Ah well, it's a good reminder to run our *own* tests even if the product comes with self-tests (like ruby 1.8.2 snapshots).

I'm glad ActiveRecord didn't put a contraint on the schema forcing us to use *only* numeric, auto-incrementing primary keys. Many of us have existing schemas with at least one text primary key--and don't have the luxury of modifying them.

···

On Sat, 11 Dec 2004 11:27:24 +0900, J. D. <jd@nospam.com> wrote: