def relbind(self, db): self.indb = db name = self.name # determine target relation target = self.target = db.get_for_update(name) targetatts = target.attributes() from sqlsem import kjbuckets kjSet = kjbuckets.kjSet targetset = kjSet(targetatts) # check or set colid bindings colids = self.optcolids if colids is None: colids = self.optcolids = target.attributes() colset = kjSet(colids) ### for now all attributes must be in colset cdiff = colset - targetset if cdiff: raise NameError, "%s: no such attributes in %s" % (cdiff.items(), name) cdiff = targetset - colset ### temporary!!! if cdiff: raise NameError, "%s: not set in insert on %s" % (cdiff.items(), name) # bind the insertspec insertspec = self.insertspec self.insertspec = insertspec = insertspec.relbind(db) # create a collector for result from sqlsem import TupleCollector collector = self.collector = TupleCollector() # get ordered list of expressions to eval on bound attributes of insertspec resultexps = insertspec.resultexps() if len(resultexps) != len(colset): raise ValueError, "result and colset of differing length %s:%s" % ( colset, resultexps) pairs = map(None, colids, resultexps) for (col, exp) in pairs: collector.addbinding(col, exp) return self
def assn1(l, c): [ (col, exp) ] = l from sqlsem import TupleCollector result = TupleCollector() result.addbinding(col, exp) return result
def select1(list, context): [ (exp, name) ] = list from sqlsem import TupleCollector result = TupleCollector() result.addbinding(name, exp) return result