Modify

Opened 7 years ago

Closed 7 years ago

Last modified 6 years ago

#13343 closed defect (fixed)

Type mismatch in Postgres DB

Reported by: ntmlod Owned by: Jun Omae
Priority: normal Component: CodeReviewerPlugin
Severity: normal Keywords: PostgreSQL
Cc: Trac Release: 1.0

Description

Now that I have enabled the explicit synchronization, every commit failed to be inserted in the codereviewer_map datatable.

2017-12-07 12:14:24,243 Trac[console] ERROR: Exception in trac-admin command:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/trac/admin/console.py", line 109, in onecmd
    rv = cmd.Cmd.onecmd(self, line) or 0
  File "/usr/lib64/python2.7/cmd.py", line 220, in onecmd
    return self.default(line)
  File "/usr/lib/python2.7/site-packages/trac/admin/console.py", line 285, in default
    return cmd_mgr.execute_command(*args)
  File "/usr/lib/python2.7/site-packages/trac/admin/api.py", line 124, in execute_command
    return f(*fargs)
  File "/usr/lib/python2.7/site-packages/trac/versioncontrol/admin.py", line 96, in _do_changeset_added
    rm.notify('changeset_added', reponame, revs)
  File "/usr/lib/python2.7/site-packages/trac/versioncontrol/api.py", line 674, in notify
    getattr(listener, event)(repos, changeset, *args)
  File "build/bdist.linux-x86_64/egg/coderev/web_ui.py", line 339, in changeset_added
    self._map(repos.reponame, changeset)
  File "build/bdist.linux-x86_64/egg/coderev/web_ui.py", line 354, in _map
    (reponame or '', changeset.rev))
  File "/usr/lib/python2.7/site-packages/trac/db/util.py", line 121, in execute
    cursor.execute(query, params)
  File "/usr/lib/python2.7/site-packages/trac/db/util.py", line 65, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
ProgrammingError: operator does not exist: text = integer
LINE 1: ...ELETE FROM codereviewer_map WHERE repo='' and changeset=8933
                                                                  ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
ProgrammingError: operator does not exist: text = integer
LINE 1: ...ELETE FROM codereviewer_map WHERE repo='' and changeset=8933
                                                                  ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.

My fix

  • coderev/web_ui.py

     
    351351
    352352        with self.env.db_transaction as db:
    353353            db("DELETE FROM codereviewer_map WHERE repo=%s and changeset=%s",
    354                (reponame or '', changeset.rev))
     354               (reponame or '', str(changeset.rev)))
    355355            if not tickets:
    356356                tickets = ['']  # we still want merges inserted
    357357            for ticket in tickets:
     
    359359                    db("""INSERT INTO codereviewer_map
    360360                        (repo,changeset,ticket,time)
    361361                       VALUES (%s,%s,%s,%s)
    362                        """, (reponame or '', changeset.rev, ticket, when))
     362                       """, (reponame or '', str(changeset.rev), ticket, when))
    363363                except Exception, e:
    364364                    self.log.warning("Unable to insert changeset "
    365365                                     "%s/%s and ticket %s into db: %s",
    366                                      changeset.rev, reponame or '',
     366                                     str(changeset.rev), reponame or '',
    367367                                     ticket, e)

Attachments (0)

Change History (2)

comment:1 Changed 7 years ago by figaro

Keywords: PostgreSQL added
Summary: Type mismatch in Postgre DBType mismatch in Postgres DB

comment:2 Changed 7 years ago by Jun Omae

Owner: set to Jun Omae
Resolution: fixed
Status: newclosed

In 17014:

CodeReviewerPlugin 1.0.0dev: fix ProgrammingError raised on PostgreSQL (closes #13343)

Initial patch by ntmlod.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
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.