def run(self): objs=[(self.A,'asparagus'), (self.B, 'bunko')] sql="""SELECT $COLUMNS FROM $TABLES WHERE asparagus.x<=200 AND asparagus.b_id=bunko.id""" res=P.fetch(objs, sql) assert len(res)==2 for r in res: a, b=r assert isinstance(a, self.A) assert isinstance(b, self.B)
def run(self): objs = [(self.A, 'asparagus'), (self.B, 'bunko')] sql = """SELECT $COLUMNS FROM $TABLES WHERE asparagus.x<=200 AND asparagus.b_id=bunko.id""" res = P.fetch(objs, sql) assert len(res) == 2 for r in res: a, b = r assert isinstance(a, self.A) assert isinstance(b, self.B)
def run(self): objs=[self.C.project('x'), 'count(id)as rubberducky'] sql=""" SELECT $COLUMNS FROM $TABLES GROUP BY x HAVING x=77 """ res=P.fetch(objs, sql) assert len(res)==1 cobj, cnt=res[0] assert cobj.x==77 assert int(cnt)==4
def run(self): objs = [self.C.project('x'), 'count(id)as rubberducky'] sql = """ SELECT $COLUMNS FROM $TABLES GROUP BY x HAVING x=77 """ res = P.fetch(objs, sql) assert len(res) == 1 cobj, cnt = res[0] assert cobj.x == 77 assert int(cnt) == 4