Forum OpenACS Development: Response to input view on postgres

Collapse
Posted by Jun Yamog on
Hi Dan,

This is the rule that is created by content_type__trigger_insert_statement

 CREATE RULE cr_foo_r AS ON INSERT TO cr_fooi 
DO INSTEAD (UPDATE cr_dummy SET val = (SELECT 
content_revision__new(new.title, (new.description)::"varchar", now(), new.mime_type, new.nls_language, 
CASE WHEN (new.text IS NULL) THEN new.data ELSE new.text END, content_symlink__resolve(new.item_id), 
new.revision_id, now(), new.creation_user, new.creation_ip) 
AS content_revision__new); INSERT INTO cr_foo (foo_id) VALUES (new.revision_id); );
By changing the rule and using cr_dummy.val instead of new.revision_id
 CREATE RULE cr_foo_r AS ON INSERT TO cr_fooi 
DO INSTEAD (UPDATE cr_dummy SET val = (SELECT 
content_revision__new(new.title, (new.description)::"varchar", now(), new.mime_type, new.nls_language, 
CASE WHEN (new.text IS NULL) THEN new.data ELSE new.text END, content_symlink__resolve(new.item_id), 
new.revision_id, now(), new.creation_user, new.creation_ip) AS 
content_revision__new); INSERT INTO cr_foo (foo_id) VALUES (cr_dummy.val); );

You are now able to insert without specifying revision_id. So we basically need to change content_type__trigger_insert_statement proc. Is this a valid solution? This is the first time I that I ventured this deep into pg so I am not sure if this thoughts are correct.