Forum OpenACS Q&A: inserting into cr_revisionsi

Collapse
Posted by Vinod Kurup on
What actually happens when you insert into the cr_revisionsi view? My site is OpenACS 5.2beta-ish and I just noticed that a couple of the CR automated tests don't work. It boils down to this:
select content_item__new('cr_test_item8AD9BD6DD',null,'41769',
    NULL,NULL,'310',NULL,'127.0.0.1',
    'content_item','content_revision',NULL,NULL,NULL,NULL,
    NULL,NULL,NULL,NULL,'file','13066');

select content_revision__new(null,null,null,null,null,'41769');

insert into cr_revisionsi (revision_id, object_type, item_id, object_package_id) 
   values ('41770', 'content_revision', '41769', '13066');
The content_revision__new call works fine, but the 'insert into cr_revisionsi' bombs with:
ERROR:  null value in column "item_id" violates not-null constraint
which is weird because the item_id is specified as 41769. Is this going to cause me problems down the road? How do I go about debugging where this error is actually coming from (i.e. what exactly happens when you insert into cr_revisionsi).
Collapse
Posted by Dave Bauer on
This is a pain to track down.

The cr_revisionsi view is created by content_type__refresh_view and content_type__regresh_trigger. The trigger inserts into the cr_revisions table.

The plpgsql procs are defined in packages/acs-content-repository/sql/postgresql/content-type.sql

One way to track it down is to add some debugging notices into refresh trigger code that end up in the actual trigger procedure. Then when you do the insert you should see the debugging messages. After redefining the plpglsql function you just run content_type__refresh_view('content_revision') to recreate the view and trigger.

Collapse
Posted by Ben Koot on
Would it be an idea to flag down 5.2 for the moment. or at least give a short writeup what it realy is, so users don't get frustrated over missing functionality.

Maybe it's an idea to upgrade OACS.org to the latest release before it's officially announced in future. That would set a benchmark.

Cheers
Ben

Collapse
Posted by Vinod Kurup on
Thanks Dave,

I started doing what you recommended and the bug fixed itself. 😊 Just calling content_type__refresh_view('content_revision') fixed the problem. At least for the moment. The CR automated test now runs completely without bombing, but one of the assertion fails (the 'item exists' one). I'll try to debug that when I get a chance.