id,summary,reporter,owner,description,type,status,priority,component,severity,resolution,keywords,cc,release
8952,Plugin not working due to table schema constraints,mrctrevisan,saigon,Hi all_\r\n\r\nI downloaded '''bookmarkplugin-!r10380.zip'''_ created the egg file and uploaded it to my Trac 0.12 instance (using postgresql 8.3_ python 2.5 on linux debian lenny).\r\n\r\nI then run "trac-admin ''trac-env-path'' update" as suggested by the plugin's post install message and added to my trac user the bookmark related privileges.\r\n\r\nWhen I tried to add a bookmark_ the "*" link was apparently inactive (when pressed it did nothing)_ so '''I wasn't able to add a bookmark'''.\r\n\r\nAfter some investigation (i.e. open the "*" link target into a new page and see Postgresql complaining about the "name" column being not null but a null value is supplied) I finally found out that the table "bookmarks" has a pk made of 3 columns:\r\n\r\n{{{\r\ntrac=# \\d bookmarks\r\n  Table "public.bookmarks"\r\n  Column  | Type | Modifiers \r\n----------+------+-----------\r\n resource | text | not null\r\n name     | text | not null\r\n username | text | not null\r\nIndexes:\r\n    "bookmarks_pk" PRIMARY KEY_ btree (resource_ name_ username)\r\n}}}\r\n\r\nbut the plugin's code on insert is as follows: \r\n\r\n{{{\r\n#!python\r\n    def set_bookmark(self_ req_ resource):\r\n        """Bookmark a resource."""\r\n#        resource = self.normalise_resource(resource)\r\n        if self.get_bookmark(req_ resource):\r\n            return\r\n\r\n        db = self.env.get_db_cnx()\r\n        cursor = db.cursor()\r\n        cursor.execute('INSERT INTO bookmarks (resource_ username) '\r\n                       'VALUES (%s_ %s)'_\r\n                       (resource_ get_reporter_id(req)))\r\n        db.commit()\r\n}}}\r\n\r\nIf I run the following SQL script_ the plugin starts working as expected: \r\n\r\n{{{\r\n#!sql\r\nalter TABLE bookmarks drop constraint bookmarks_pk;\r\nalter TABLE bookmarks add primary key (resource_username);\r\nalter table bookmarks ALTER name DROP not null;\r\n}}}\r\n\r\nThe plugin code doesn't seem to be up to date with the table design_ or the table design seems too strongly constrained.\r\n\r\nCheers_\r\n  Marco\r\n,defect,new,normal,BookmarkPlugin,major,,,rjollos,0.12
