Opened 14 years ago
Last modified 6 years ago
#8952 new defect
Plugin not working due to table schema constraints
| Reported by: | mrctrevisan | Owned by: | yosiyuki | 
|---|---|---|---|
| Priority: | normal | Component: | BookmarkPlugin | 
| Severity: | major | Keywords: | |
| Cc: | Trac Release: | 0.12 | 
Description
Hi all,
I 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).
I 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.
When 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.
After 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:
trac=# \d bookmarks
  Table "public.bookmarks"
  Column  | Type | Modifiers 
----------+------+-----------
 resource | text | not null
 name     | text | not null
 username | text | not null
Indexes:
    "bookmarks_pk" PRIMARY KEY, btree (resource, name, username)
but the plugin's code on insert is as follows:
def set_bookmark(self, req, resource): """Bookmark a resource.""" # resource = self.normalise_resource(resource) if self.get_bookmark(req, resource): return db = self.env.get_db_cnx() cursor = db.cursor() cursor.execute('INSERT INTO bookmarks (resource, username) ' 'VALUES (%s, %s)', (resource, get_reporter_id(req))) db.commit()
If I run the following SQL script, the plugin starts working as expected:
alter TABLE bookmarks drop constraint bookmarks_pk; alter TABLE bookmarks add primary key (resource,username); alter table bookmarks ALTER name DROP not null;
The plugin code doesn't seem to be up to date with the table design, or the table design seems too strongly constrained.
Cheers,
Marco
Attachments (0)
Change History (3)
comment:1 Changed 14 years ago by
| Cc: | Ryan J Ollos added; anonymous removed | 
|---|
comment:2 Changed 13 years ago by
comment:3 Changed 6 years ago by
| Cc: | Ryan J Ollos removed | 
|---|




(In [11901]) bookmarkplugin: refs #8952, workaround, uses empty string instead of NULL for name column when inserting bookmarks record