Modify

Opened 2 years ago

Last modified 11 months ago

#8952 new defect

Plugin not working due to table schema constraints

Reported by: mrctrevisan Owned by: saigon
Priority: normal Component: BookmarkPlugin
Severity: major Keywords:
Cc: rjollos 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 (2)

comment:1 Changed 19 months ago by rjollos

  • Cc rjollos added

comment:2 Changed 11 months ago by jun66j5

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as new .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from saigon. Next status will be 'new'.
The owner will be changed from saigon to anonymous. Next status will be 'assigned'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.