Modify

Opened 19 years ago

Closed 17 years ago

#333 closed defect (fixed)

Plugin does not work with postgreSQL

Reported by: anonymous Owned by: Sebastian Marek
Priority: high Component: PeerReviewPlugin
Severity: major Keywords:
Cc: Trac Release: 0.11

Description (last modified by Sebastian Marek)

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 (0)

Change History (19)

comment:1 Changed 17 years ago by anonymous

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

comment:2 Changed 17 years ago by anonymous

Priority: normalhigh

this is error in mysql too.

comment:3 Changed 17 years ago by Sebastian Marek

Description: modified (diff)
Owner: changed from Team5 to Sebastian Marek

Will have a look at it.

comment:4 Changed 17 years ago by Sebastian Marek

Status: newassigned

comment:5 Changed 17 years ago by Ben Selby

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

comment:6 Changed 17 years ago by Ben Selby

Owner: changed from Sebastian Marek to Ben Selby
Status: assignednew

comment:7 Changed 17 years ago by Ben Selby

Cc: Sebastian Marek added; anonymous removed

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.

comment:8 Changed 17 years ago by Ben Selby

Cc: anonymous added; Sebastian Marek removed
Status: newassigned

comment:9 in reply to:  8 Changed 17 years ago by anonymous

Trac Release: 0.90.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.

comment:10 Changed 17 years ago by anonymous

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

comment:11 in reply to:  10 Changed 17 years ago 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.

comment:12 Changed 17 years ago by Sebastian Marek

Status: assignednew

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.

comment:13 Changed 17 years ago by Ben Selby

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!!

comment:14 in reply to:  13 Changed 17 years ago by Sebastian Marek

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!

comment:15 Changed 17 years ago by Ben Selby

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

comment:16 Changed 17 years ago by anonymous

Resolution: fixed
Status: newclosed

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.

comment:17 Changed 17 years ago by anonymous

Resolution: fixed
Severity: normalmajor
Status: closedreopened

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

comment:18 Changed 17 years ago by Sebastian Marek

Owner: changed from Ben Selby to Sebastian Marek
Status: reopenednew

Now did some cleanup and fixed bug causing reported issue.

comment:19 Changed 17 years ago by Sebastian Marek

Resolution: fixed
Status: newclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Sebastian Marek.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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

 
Note: See TracTickets for help on using tickets.