]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
add schema to entity method
authorJonathan Ellis <jbellis@gmail.com>
Mon, 9 Mar 2009 21:24:43 +0000 (21:24 +0000)
committerJonathan Ellis <jbellis@gmail.com>
Mon, 9 Mar 2009 21:24:43 +0000 (21:24 +0000)
lib/sqlalchemy/ext/sqlsoup.py

index f2754793b0e53a18ee806667823717abe6d69d8e..b3f2de743ef5c94e91b2162a1920c9eca0f97e21 100644 (file)
@@ -286,6 +286,9 @@ You can load a table whose name is specified at runtime with the entity() method
     >>> db.entity(tablename) == db.loans
     True
 
+entity() also takes an optional schema argument.  If none is specified, the
+default schema is used.
+
 
 Extra tests
 ===========
@@ -537,11 +540,11 @@ class SqlSoup:
         j = join(*args, **kwargs)
         return self.map(j)
 
-    def entity(self, attr):
+    def entity(self, attr, schema=None):
         try:
             t = self._cache[attr]
         except KeyError:
-            table = Table(attr, self._metadata, autoload=True, schema=self.schema)
+            table = Table(attr, self._metadata, autoload=True, schema=schema or self.schema)
             if not table.primary_key.columns:
                 raise PKNotFoundError('table %r does not have a primary key defined [columns: %s]' % (attr, ','.join(table.c.keys())))
             if table.columns: