Rails core bug with set_sequence_name [www.ruby-forum.com]
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]
12:12 AM, 21 Dec 2009 by Jade Rubick Permalink | Comments (0)
OpenACS on Rails [github.com]
If you're interested in doing the same or collaborating, fork away on Github!
09:18 AM, 19 Dec 2009 by Jade Rubick Permalink | Comments (0)
Is your code reentrant? [en.wikipedia.org]
08:30 AM, 19 Dec 2009 by Jade Rubick Permalink | Comments (0)
| December 2009 | ||||||
| S | M | T | W | T | F | S |
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | 31 | ||