server/sources/native.py
branchstable
changeset 9130 0f1504a9fb51
parent 8947 3bbd416b09ec
child 9131 b3ad80aa645f
equal deleted inserted replaced
9129:6c4ae3a06619 9130:0f1504a9fb51
   755                 except Exception as ex:
   755                 except Exception as ex:
   756                     pass
   756                     pass
   757             if ex.__class__.__name__ == 'IntegrityError':
   757             if ex.__class__.__name__ == 'IntegrityError':
   758                 # need string comparison because of various backends
   758                 # need string comparison because of various backends
   759                 for arg in ex.args:
   759                 for arg in ex.args:
   760                     mo = re.search('unique_cw_[^ ]+_idx', arg)
   760                     # postgres and sqlserver
       
   761                     mo = re.search('"unique_cw_[^ ]+"', arg)
   761                     if mo is not None:
   762                     if mo is not None:
   762                         index_name = mo.group(0)
   763                         index_name = mo.group(0)[1:-1] # eat the surrounding " pair
   763                         # right-chop '_idx' postfix
   764                         elements = index_name.split('_cw_')[1:]
   764                         # (garanteed to be there, see regexp above)
       
   765                         elements = index_name[:-4].split('_cw_')[1:]
       
   766                         etype = elements[0]
   765                         etype = elements[0]
   767                         rtypes = elements[1:]
   766                         rtypes = elements[1:]
   768                         raise UniqueTogetherError(etype, rtypes)
   767                         raise UniqueTogetherError(etype, rtypes)
       
   768                     # sqlite
   769                     mo = re.search('columns (.*) are not unique', arg)
   769                     mo = re.search('columns (.*) are not unique', arg)
   770                     if mo is not None: # sqlite in use
   770                     if mo is not None: # sqlite in use
   771                         # we left chop the 'cw_' prefix of attribute names
   771                         # we left chop the 'cw_' prefix of attribute names
   772                         rtypes = [c.strip()[3:]
   772                         rtypes = [c.strip()[3:]
   773                                   for c in mo.group(1).split(',')]
   773                                   for c in mo.group(1).split(',')]