Contact: fumanchu@aminus.org

Log in as guest/geniusql to create tickets

Changeset 17

Show
Ignore:
Timestamp:
02/17/07 21:17:50
Author:
fumanchu
Message:

New doc folder. Also removed Table.use_asterisk_to_delete_all. Also changed Table.select_all to return a list rather than yield rows (use Table._select_lazy to do that now).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/geniusql/objects.py

    r16 r17  
    381381            self.schema.db.execute(sql) 
    382382     
    383     use_asterisk_to_delete_all = False 
    384      
    385383    def delete(self, **inputs): 
    386384        """Delete all rows matching the given identifier inputs.""" 
    387         if self.use_asterisk_to_delete_all: 
    388             star = " *" 
    389         else: 
    390             star = "" 
    391         self.schema.db.execute('DELETE%s FROM %s WHERE %s;' % 
    392                                (star, self.qname, self.id_clause(**inputs))) 
     385        self.schema.db.execute('DELETE FROM %s WHERE %s;' % 
     386                               (self.qname, self.id_clause(**inputs))) 
    393387     
    394388    def delete_all(self, **inputs): 
    395389        """Delete all rows matching the given inputs.""" 
    396         if self.use_asterisk_to_delete_all: 
    397             star = " *" 
    398         else: 
    399             star = "" 
    400         self.schema.db.execute('DELETE%s FROM %s WHERE %s;' % 
    401                                (star, self.qname, 
    402                                 self.whereclause(**inputs))) 
     390        self.schema.db.execute('DELETE FROM %s WHERE %s;' % 
     391                               (self.qname, self.whereclause(**inputs))) 
    403392     
    404393    def select(self, restriction=None, **kwargs): 
    405394        """Return a single data dict matching the given restriction (or None).""" 
    406395        try: 
    407             return self.select_all(restriction, **kwargs).next() 
     396            return self._select_lazy(restriction, **kwargs).next() 
    408397        except StopIteration: 
    409398            return None 
    410399     
    411400    def select_all(self, restriction=None, **kwargs): 
     401        """Return a list of all data dicts matching the given restriction.""" 
     402        return list(self._select_lazy(restriction, **kwargs)) 
     403     
     404    def _select_lazy(self, restriction=None, **kwargs): 
    412405        """Yield data dicts matching the given restriction.""" 
    413406        if restriction and not isinstance(restriction, logic.Expression): 
  • trunk/geniusql/providers/ado.py

    r16 r17  
    10591059class MSAccessTable(ADOTable): 
    10601060     
    1061     use_asterisk_to_delete_all = True 
     1061    def delete(self, **inputs): 
     1062        """Delete all rows matching the given identifier inputs.""" 
     1063        # MS Access needs an asterisk to delete 
     1064        self.schema.db.execute('DELETE * FROM %s WHERE %s;' % 
     1065                               (self.qname, self.id_clause(**inputs))) 
     1066     
     1067    def delete_all(self, **inputs): 
     1068        """Delete all rows matching the given inputs.""" 
     1069        # MS Access needs an asterisk to delete 
     1070        self.schema.db.execute('DELETE * FROM %s WHERE %s;' % 
     1071                               (self.qname, self.whereclause(**inputs))) 
    10621072     
    10631073    def _grab_new_ids(self, idkeys, conn): 
  • trunk/geniusql/test/zoo_fixture.py

    r16 r17  
    1 """Test fixture for Storage Managers.""" 
     1"""Test fixture for Geniusql.""" 
    22 
    33import datetime 
     
    308308         
    309309        # Exhibits 
    310         exes = list(schema['Exhibit'].select_all()
     310        exes = schema['Exhibit'].select_all(
    311311        self.assertEqual(len(exes), 2) 
    312312        if exes[0]['Name'] == 'The Penguin Encounter': 
     
    329329    def test_4_Expressions(self): 
    330330        def matches(lam, tkey='Animal'): 
    331             return len(list(schema[tkey].select_all(lam))) 
     331            return len(schema[tkey].select_all(lam)) 
    332332         
    333333        self.assertEqual(matches(None, 'Zoo'), 4) 
     
    798798            # Read City 1 
    799799            self.boxid = 1 
    800             pvets = list(schema['Vet'].select_all(City = 'Poughkeepsie')
     800            pvets = schema['Vet'].select_all(City = 'Poughkeepsie'
    801801            assert len(pvets) == 0 
    802802             
     
    809809            # Re-read City 1 
    810810            self.boxid = 1 
    811             pvets = list(schema['Vet'].select_all(City = 'Poughkeepsie')
     811            pvets = schema['Vet'].select_all(City = 'Poughkeepsie'
    812812            # If REPEATABLE READ or lower, this should fail 
    813813            assert len(pvets) == 0 
     
    829829            # we only assert the unchanged data, since the order of 
    830830            # thread execution can not be guaranteed. 
    831             quadrupeds = list(schema['Animal'].select_all(f)
     831            quadrupeds = schema['Animal'].select_all(f
    832832            self.assertEqual(len(quadrupeds), 4) 
    833833            first = quadrupeds[0]