server/sources/native.py
branchstable
changeset 9130 0f1504a9fb51
parent 8947 3bbd416b09ec
child 9131 b3ad80aa645f
--- a/server/sources/native.py	Wed Jul 03 14:16:21 2013 +0200
+++ b/server/sources/native.py	Wed Jul 03 14:33:27 2013 +0200
@@ -757,15 +757,15 @@
             if ex.__class__.__name__ == 'IntegrityError':
                 # need string comparison because of various backends
                 for arg in ex.args:
-                    mo = re.search('unique_cw_[^ ]+_idx', arg)
+                    # postgres and sqlserver
+                    mo = re.search('"unique_cw_[^ ]+"', arg)
                     if mo is not None:
-                        index_name = mo.group(0)
-                        # right-chop '_idx' postfix
-                        # (garanteed to be there, see regexp above)
-                        elements = index_name[:-4].split('_cw_')[1:]
+                        index_name = mo.group(0)[1:-1] # eat the surrounding " pair
+                        elements = index_name.split('_cw_')[1:]
                         etype = elements[0]
                         rtypes = elements[1:]
                         raise UniqueTogetherError(etype, rtypes)
+                    # sqlite
                     mo = re.search('columns (.*) are not unique', arg)
                     if mo is not None: # sqlite in use
                         # we left chop the 'cw_' prefix of attribute names