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
