schema.py
branchstable
changeset 6233 612b7d947a4c
parent 6232 d992176d17b7
child 6262 84901d735156
equal deleted inserted replaced
6232:d992176d17b7 6233:612b7d947a4c
   748         return self.exec_query(session, eidfrom, eidto)
   748         return self.exec_query(session, eidfrom, eidto)
   749 
   749 
   750 
   750 
   751 class RQLUniqueConstraint(RepoEnforcedRQLConstraintMixIn, BaseRQLConstraint):
   751 class RQLUniqueConstraint(RepoEnforcedRQLConstraintMixIn, BaseRQLConstraint):
   752     """the unique rql constraint check that the result of the query isn't
   752     """the unique rql constraint check that the result of the query isn't
   753     greater than one
   753     greater than one.
   754     """
   754 
       
   755     You *must* specify mainvars when instantiating the constraint since there is
       
   756     no way to guess it correctly (e.g. if using S,O or U the constraint will
       
   757     always be satisfied because we've to use a DISTINCT query).
       
   758     """
       
   759     # XXX turns mainvars into a required argument in __init__
   755     distinct_query = True
   760     distinct_query = True
   756 
       
   757     # XXX turns mainvars into a required argument in __init__, since we've no
       
   758     #     way to guess it correctly (eg if using S,O or U the constraint will
       
   759     #     always be satisfied since we've to use a DISTINCT query)
       
   760 
   761 
   761     def match_condition(self, session, eidfrom, eidto):
   762     def match_condition(self, session, eidfrom, eidto):
   762         return len(self.exec_query(session, eidfrom, eidto)) <= 1
   763         return len(self.exec_query(session, eidfrom, eidto)) <= 1
   763 
   764 
   764 
   765