Modify

Opened 8 years ago

Closed 8 years ago

#790 closed defect (fixed)

DiscussionPlugin doesn't work for me with sqlite db backend

Reported by: imme Owned by: Blackhex
Priority: normal Component: DiscussionPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.10

Description

When I try to use the DiscussionPlugin with project using sqlite, I get the following error (trac 0.10, python 2.3, apache2 + mod_python):

Traceback (most recent call last):
  File "/usr/lib/python2.3/site-packages/trac/web/main.py", line 356, in dispatch_request
    dispatcher.dispatch(req)
  File "/usr/lib/python2.3/site-packages/trac/web/main.py", line 224, in dispatch
    resp = chosen_handler.process_request(req)
  File "build/bdist.linux-x86_64/egg/tracdiscussion/core.py", line 70, in process_request
  File "build/bdist.linux-x86_64/egg/tracdiscussion/api.py", line 31, in render_discussion
  File "build/bdist.linux-x86_64/egg/tracdiscussion/api.py", line 366, in _do_action
  File "build/bdist.linux-x86_64/egg/tracdiscussion/api.py", line 809, in get_groups
  File "/usr/lib/python2.3/site-packages/trac/db/util.py", line 48, in execute
    return self.cursor.execute(sql)
  File "/usr/lib/python2.3/site-packages/sqlite/main.py", line 244, in execute
    self.rs = self.con.db.execute(SQL)
DatabaseError: no such column: forum_group.id

I made sure, that the table is in the database. The output from sqlite (".schema forum_group"):

CREATE TABLE forum_group (
    id integer PRIMARY KEY,
    name text,
    description text
);

I can't see, what is wrong here. Curiously everything works fine for me with a MySQL backend.

Attachments (2)

discussion-plugin-0.5-sqlite-2.8.16.patch (3.8 KB) - added by sto 8 years ago.
Revised patch, timeline.py was missing
discussion-plugin-r1491-sqlite-2.8.16.patch (8.6 KB) - added by sto 8 years ago.
New patch, removes nested queries

Download all attachments as: .zip

Change History (14)

comment:1 in reply to: ↑ description Changed 8 years ago by schuetze@…

I also have this problem with TRAC 0.10 and SQLite. Please check this ... Thx!

comment:2 Changed 8 years ago by Blackhex

  • Status changed from new to assigned

What version of sqlite is your pysqlite using?

comment:3 Changed 8 years ago by Blackhex

In changesets 1375 and 1376 are commited some changes in SQL statements which could help but I'm not sure if they could work. Please try and let me know.

comment:4 Changed 8 years ago by dimi3

I have SQLite version 2.8.16, I've installed the Discussion Plugin and I have the appropriate tables in db, but I get the error.

comment:5 Changed 8 years ago by Blackhex

Try to upgrade to sqlite3 if you can, I'm not sure if Trac 0.10 can be run with sqlite2. If it can, I'll have to rewrite SQL statements somehow, but I don't know how to make them compatible with sqlite2 for now.

comment:6 Changed 8 years ago by sto

I've attached the patch attachment:"discussion-plugin-0.5-sqlite-2.8.16.patch"
to this ticket.

That fixes the problem for me using trac 0.10 with sqlite version 2.8.16, it seems that
this version's sql parser is not as clever as expected.

Changed 8 years ago by sto

Revised patch, timeline.py was missing

comment:7 Changed 8 years ago by Blackhex

Thank you very much for your patch. I knew that problem was with that nested SELECTs but I did't see that solution is so simple. I've commited 1482 to repository, so please try if 0.10 branch works for you now.

comment:8 Changed 8 years ago by sto

I've replaced my patched plugin by an export from svn and it works OK.

I've seen that I missed more query changes (i.e. for the wiki) but
luckily the plugin author knows the code better than me ;)

I believe that you can close the bug.

comment:9 Changed 8 years ago by Blackhex

  • Resolution set to fixed
  • Status changed from assigned to closed

Ok, thank you.

comment:10 Changed 8 years ago by sto

  • Resolution fixed deleted
  • Status changed from closed to reopened

After using the patched version I've detected that the queries for
the fields Last Topic, Last Reply, Topics and Replies are
wrong (they always show the values for all forums).

Tomorrow I'll try to build a working patch, now it is time to go home.


Changed 8 years ago by sto

New patch, removes nested queries

comment:11 Changed 8 years ago by sto

I've attached a new patch that removes nested SQL queries, now my tests succeed,
but the SQL code looks a little bit uglier; use this patch or revert the old one,
the previous patch is wrong for all SQL databases.

comment:12 Changed 8 years ago by Blackhex

  • Resolution set to fixed
  • Status changed from reopened to closed

Your patch seem to work well. I've commited it. Thank you.

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


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

 
Note: See TracTickets for help on using tickets.