Modify

Opened 4 years ago

Closed 4 years ago

#8411 closed defect (fixed)

error when create new type

Reported by: okamototk Owned by: farialima
Priority: normal Component: TicketImportPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.12

Description

When create new type, plugin output following error:

2011-01-18 22:18:12,101 Trac[main] ERROR: Internal Server Error: 
Traceback (most recent call last):
  File "build\bdist.win32\egg\trac\web\main.py", line 511, in _dispatch_request
    dispatcher.dispatch(req)
  File "build\bdist.win32\egg\trac\web\main.py", line 237, in dispatch
    resp = chosen_handler.process_request(req)
  File "build\bdist.win32\egg\talm_importer\importer.py", line 76, in process_request
    return self._do_import(req.session['uploadedfile'], int(req.session['sheet']), req, req.session['uploadedfilename'], tickettime)
  File "build\bdist.win32\egg\talm_importer\importer.py", line 118, in _do_import
    return self._process(filereader, get_reporter_id(req), ImportProcessor(self.env, req, uploadedfilename, tickettime))
  File "build\bdist.win32\egg\talm_importer\importer.py", line 369, in _process
    processor.process_new_lookups(newvalues)
  File "build\bdist.win32\egg\talm_importer\processors.py", line 156, in process_new_lookups
    lookup.insert()
  File "build\bdist.win32\egg\trac\ticket\model.py", line 709, in insert
    @self.env.with_transaction(db)
  File "build\bdist.win32\egg\trac\db\api.py", line 77, in transaction_wrapper
    fn(ldb)
  File "build\bdist.win32\egg\trac\ticket\model.py", line 720, in do_insert
    (self.type, self.name, self.value))
  File "build\bdist.win32\egg\trac\db\util.py", line 65, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
  File "build\bdist.win32\egg\trac\db\sqlite_backend.py", line 78, in execute
    result = PyFormatCursor.execute(self, *args)
  File "build\bdist.win32\egg\trac\db\sqlite_backend.py", line 56, in execute
    args or [])
  File "build\bdist.win32\egg\trac\db\sqlite_backend.py", line 48, in _rollback_on_error
    return function(self, *args, **kwargs)
IntegrityError: columns type, name are not unique

ticket type is 'ticket_type' enum but plugin treat just 'type'.
Following patch fixed the problem.

Index: processors.py
===================================================================
--- processors.py       (revision 9770)
+++ processors.py       (working copy)
@@ -134,6 +134,9 @@
             elif field == 'version':
                 class CurrentLookupEnum(model.Version):
                     pass
+            elif field == 'type':
+                class CurrentLookupEnum(model.Type):
+                    pass
             else:
                 class CurrentLookupEnum(model.AbstractEnum):
                     # here, you shouldn't put 'self.' before the class field.

best regards,

Takashi Okamoto

Attachments (0)

Change History (1)

comment:1 Changed 4 years ago by farialima

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

Good catch, thank you - patch slighly improved and commited in [9772], with test.

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.