Ticket #333 (closed defect: fixed)

Opened 2 years ago

Last modified 1 month ago

Plugin does not work with postgreSQL

Reported by: anonymous Assigned to: proofek
Priority: high Component: PeerReviewPlugin
Severity: major Keywords:
Cc: Trac Release: 0.11

Description (Last modified by proofek)

Trac detected an internal error:

ERROR: null value in column "idreview" violates not-null constraint

INSERT INTO CodeReviews? VALUES(NULL,'tlb','Open for review','1145886444','Find bugs in code','Find bugs')

Attachments

Change History

08/02/07 15:37:58 changed by anonymous

Ouch. I was considering this plugin but we also use PostgreSQL for our Trac db. Any plans to support PostgreSQL-based Trac?

01/04/08 10:02:55 changed by anonymous

  • priority changed from normal to high.

this is error in mysql too.

04/03/08 16:57:17 changed by proofek

  • owner changed from Team5 to proofek.
  • description changed.

Will have a look at it.

04/03/08 16:57:45 changed by proofek

  • status changed from new to assigned.

04/07/08 11:08:55 changed by bselby

Currently tested this on mysql 5.0.45 and it worked first time. Will give some further investigation, and make some changes to the SQL query and retest. Then move onto PostgreSQL

04/09/08 02:25:48 changed by bselby

  • owner changed from proofek to bselby.
  • status changed from assigned to new.

04/09/08 10:16:40 changed by bselby

  • cc set to proofek.

Changed the SQL so that it works in MySQL and SQLite, however cannot seem to get the plugin loaded for Postgres even through the rest of the site still works.

Proofek will test this on his local version tonight.

(follow-up: ↓ 9 ) 04/09/08 10:17:11 changed by bselby

  • cc deleted.
  • status changed from new to assigned.

(in reply to: ↑ 8 ) 04/09/08 14:49:31 changed by anonymous

  • release changed from 0.9 to 0.11.

Replying to bselby:

OK, it's better now, but no ideal I am affraid. It is creating the code review, but raises horrible error screen as well:

2008-04-09 20:40:38,237 Trac[init] ERROR: current transaction is aborted, commands ignored until end of transaction block Traceback (most recent call last):

File "/usr/lib/python2.5/site-packages/Trac-0.11b1-py2.5.egg/trac/web/main.py", line 398, in _dispatch_request

dispatcher.dispatch(req)

File "/usr/lib/python2.5/site-packages/Trac-0.11b1-py2.5.egg/trac/web/main.py", line 195, in dispatch

resp = chosen_handler.process_request(req)

File "build/bdist.linux-i686/egg/codereview/peerReviewNew.py", line 137, in process_request

returnid = self.createCodeReview(req)

File "build/bdist.linux-i686/egg/codereview/peerReviewNew.py", line 190, in createCodeReview

struct.save(self.env.get_db_cnx())

File "build/bdist.linux-i686/egg/codereview/ReviewerStruct.py", line 46, in save

cursor.execute(query)

File "/usr/lib/python2.5/site-packages/Trac-0.11b1-py2.5.egg/trac/db/util.py", line 51, in execute

return self.cursor.execute(sql)

File "/usr/lib/python2.5/site-packages/Trac-0.11b1-py2.5.egg/trac/db/util.py", line 51, in execute

return self.cursor.execute(sql)

ProgrammingError?: current transaction is aborted, commands ignored until end of transaction block

On it now.

(follow-up: ↓ 11 ) 04/09/08 15:08:49 changed by anonymous

Is this using postgres as I tested SQLite and MySQL and it worked fine on machine!

(in reply to: ↑ 10 ) 04/09/08 16:45:25 changed by anonymous

Replying to anonymous:

Is this using postgres as I tested SQLite and MySQL and it worked fine on machine!

This is affecting postgresql only at the mo.

04/09/08 16:58:00 changed by proofek

  • status changed from assigned to new.

Right, we have multiple problems in here. I'll try to explain you as much as I can.

First table structure needs to be fixed in db_default.py:

Table('CodeReviews?', key='IDReview')[

Column('IDReview', auto_increment=True, type='int'), Column('Author'), Column('Status'), Column('DateCreate?', type='int'), Column('Name'), Column('Notes'),

],

Next the way how auto increment value is retrieved. Review all Struct files and make sure we use db.get_last_id(cursor, 'tableName', 'columnName') instead of cursor.lastrowid

Then we need to get rid of horrible dbEscape() in every query execution. It messes things up. Just do something like that:

query = "INSERT INTO table (intCol, stringCol) VALUES (%d, '%s')" % (1, 'String')

And finally in peerReviewNew.py, line 188:

struct.Status = 'Not Reviewed'

struct.Status is INTEGER!! Just insert there 0 - i don't think it is used anywhere else

Ahhh.. one more thing.. at least one INSERT left with NULL as auto_increment value - check it out.

That eventually should resolve all the problems with Db backend.

(follow-up: ↓ 14 ) 04/10/08 08:42:51 changed by bselby

OK, I have made the changes, but still having issues.

Cannot currently get the queries to use the format below on some of the fields. I think that the type formatting is incorrect, so need to get more into python and what is possible

cursor.execute("INSERT INTO table () VALUES ()", (args));

I have not checked into toddler until it is working.

Also, of note, it looks like the trac db.get_last_id(cursor, 'table', 'column') does not work on MySQL!!

(in reply to: ↑ 13 ) 04/10/08 14:25:23 changed by proofek

Replying to bselby:

OK Ben, mystery solved!

Cannot currently get the queries to use the format below on some of the fields. I think that the type formatting is incorrect, so need to get more into python and what is possible cursor.execute("INSERT INTO table () VALUES ()", (args));

Always use %s despite the variable type

I have not checked into toddler until it is working. Also, of note, it looks like the trac db.get_last_id(cursor, 'table', 'column') does not work on MySQL!!

It's the order that is important - first get last inserted id, then commit the transaction ;)

I hope that will work this time. Good luck!

04/12/08 10:38:33 changed by bselby

I have tested this on SQLite, MySQL and Postgres and it all seems to work fine now. Checked in the following files:

peerreviewplugin/branches/2.1-toddler/codereview/db_default.py peerreviewplugin/branches/2.1-toddler/codereview/CodeReviewStruct.py peerreviewplugin/branches/2.1-toddler/codereview/ReviewCommentStruct.py peerreviewplugin/branches/2.1-toddler/codereview/ReviewerStruct.py peerreviewplugin/branches/2.1-toddler/codereview/ReviewFilesStruct.py peerreviewplugin/branches/2.1-toddler/codereview/peerReviewNew.py

However, there are other files such as:

peerreviewplugin/branches/2.1-toddler/codereview/dbBackend.py

that should get updated and use the new structure of the database query.

Also need to remove the try and catch in:

peerreviewplugin/branches/2.1-toddler/codereview/ReviewerStruct.py

05/01/08 04:44:14 changed by anonymous

  • status changed from new to closed.
  • resolution set to fixed.

Updated the dbBackend.py file so it no longer needs dbEscape.py file. Closing the ticket.

Any issues with SQL now, please raise as seperate ticket.

05/14/08 05:15:52 changed by anonymous

  • status changed from closed to reopened.
  • resolution deleted.
  • severity changed from normal to major.

I receive following errors with this branch:

Traceback (most recent call last):

File "/usr/lib/python2.4/site-packages/Trac-0.11b2-py2.4.egg/trac/web/main.py", line 419, in _dispatch_request

dispatcher.dispatch(req)

File "/usr/lib/python2.4/site-packages/Trac-0.11b2-py2.4.egg/trac/web/main.py", line 196, in dispatch

resp = chosen_handler.process_request(req)

File "build/bdist.linux-i686/egg/codereview/peerReviewView.py", line 102, in process_request File "build/bdist.linux-i686/egg/codereview/dbBackend.py", line 55, in getVotesByID

TypeError?: not enough arguments for format string

Traceback (most recent call last):

File "/usr/lib/python2.4/site-packages/Trac-0.11b2-py2.4.egg/trac/web/main.py", line 419, in _dispatch_request

dispatcher.dispatch(req)

File "/usr/lib/python2.4/site-packages/Trac-0.11b2-py2.4.egg/trac/web/main.py", line 196, in dispatch

resp = chosen_handler.process_request(req)

File "build/bdist.linux-i686/egg/codereview/peerReviewMain.py", line 97, in process_request File "build/bdist.linux-i686/egg/codereview/dbBackend.py", line 99, in getReviewerEntry

TypeError?: not enough arguments for format string

System Information:

User Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14 Trac: 0.11b2 Python: 2.4.4 (#1, Apr 5 2007, 20:09:06) [GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] setuptools: 0.6c3 psycopg2: 2.0.5.1 (dec mx dt ext pq3) Genshi: 0.4.4 mod_python: 3.2.10 Pygments: 0.9 Subversion: 1.4.2 (r22196) jQuery: 1.2.3

05/27/08 16:55:23 changed by proofek

  • owner changed from bselby to proofek.
  • status changed from reopened to new.

Now did some cleanup and fixed bug causing reported issue.

05/27/08 16:55:54 changed by proofek

  • status changed from new to closed.
  • resolution set to fixed.

Add/Change #333 (Plugin does not work with postgreSQL)




Change Properties
Action