~chipaca/u1db/prune-conflicts-automerges

« back to all changes in this revision

Viewing changes to u1db/backends/sqlite_backend.py

  • Committer: john.lenton at canonical
  • Date: 2012-05-20 15:50:51 UTC
  • mfrom: (292.1.5 u1db)
  • Revision ID: john.lenton@canonical.com-20120520155051-rdumhzm7dit3ks5l
[r=jameinel] make all backends fail in approx the same way on duplicated indexes

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import os
21
21
import simplejson
22
22
from sqlite3 import dbapi2
 
23
import sys
23
24
import time
24
25
import uuid
25
26
 
693
694
            cur_fields = self._get_indexed_fields()
694
695
            definition = [(index_name, idx, field)
695
696
                          for idx, field in enumerate(index_expression)]
696
 
            c.executemany("INSERT INTO index_definitions VALUES (?, ?, ?)",
697
 
                          definition)
 
697
            try:
 
698
                c.executemany("INSERT INTO index_definitions VALUES (?, ?, ?)",
 
699
                              definition)
 
700
            except dbapi2.IntegrityError as e:
 
701
                raise errors.IndexNameTakenError, e, sys.exc_info()[2]
698
702
            new_fields = set([f for f in index_expression
699
703
                              if f not in cur_fields])
700
704
            if new_fields: