Jade's weblog Archive

I read in various places that you could use set_sequence_name is your Rails models:

class ForumsForum < ActiveRecord::Base
set_primary_key :forum_id
set_sequence_name 't_acs_object_id_seq'
...
end

However, Rails seems to completely ignore this directive for Postgres. I think it does work for Oracle, but it really does not seem to for Postgres.

Here's a unit test:

def test_save_message
forum = ForumsForum.new(:name => 'Test forum', \
:charter => 'Test charter', \
:presentation_type => 'abc', \
:posting_policy => 'abc', \
:enabled_p => 'f')
forum.save
...
end

Here's the result of the test:

1) Error:
test_save_message(ForumsMessageTest):
ActiveRecord::StatementInvalid: PGError: ERROR: null value in column "forum_id" violates not-null constraint
: INSERT INTO "forums_forums" ("name", "package_id", "last_post", "thread_count", "approved_thread_count", "max_child_sortkey", "charter", "posting_policy", "presentation_type", "enabled_p") VALUES(E'Test forum', NULL, NULL, 0, 0, NULL, E'Test charter', E'abc', E'abc', E'f') RETURNING "forum_id"
test/unit/forums_message_test.rb:20:in `test_save_message'

1 tests, 0 assertions, 0 failures, 1 errors


Note the RETURNING statement. All variations I tried to set_sequence_name did not work. After a little looking, I saw this:

http://www.ruby-forum.com/topic/81873

And looking into the Rails source code, at first glance it does appear that the sequence name is not honored.

I think my next step is going to be to set up edge rails, verify the issue, and write a patch. And I guess I may backport it as well.

If anyone knows a workaround, I'd love to hear it.

10:32 AM, 21 Dec 2009 by Jade Rubick Permalink | Comments (1)

Git interactive add [book.git-scm.com]

Interesting interactive mode for Git. The coolest thing is that you can split hunks from the same file and commit them in separate commits.

12:12 AM, 21 Dec 2009 by Jade Rubick Permalink | Comments (0)

XML

Notifications

You may request notification for Jade's weblog.

Syndication Feed

XML

Recent Comments

  1. Jade Rubick: And... yes and no
  2. Jade Rubick: Using hoptoad
  3. Jade Rubick: Much better
  4. Bodo Tasche: Link changed :)
  5. Bodo Tasche: Better commt emails. Now with color :)
  6. Jade Rubick: Filed a ticket
  7. Vinod Kurup: Wow
  8. Jade Rubick: Then what
  9. Paul Post: Percentages
  10. Paul Post: I might be an ENFJ?