"set" not available/ordering is needed.
- "foreignkey" argument to relation() can also be a list. fixed
auto-foreignkey detection [ticket:151]
+- fixed bug where tables with schema names werent getting indexed in
+the MetaData object properly
0.2.2
- big improvements to polymorphic inheritance behavior, enabling it
Column("constraint_name", String),
schema="information_schema")
-mysql_key_constraints = schema.Table("key_column_usage", ischema,
- Column("table_schema", String),
- Column("table_name", String),
- Column("column_name", String),
- Column("constraint_name", String),
- Column("referenced_table_schema", String),
- Column("referenced_table_name", String),
- Column("referenced_column_name", String),
- schema="information_schema")
+#mysql_key_constraints = schema.Table("key_column_usage", ischema,
+# Column("table_schema", String),
+# Column("table_name", String),
+# Column("column_name", String),
+# Column("constraint_name", String),
+# Column("referenced_table_schema", String),
+# Column("referenced_table_name", String),
+# Column("referenced_column_name", String),
+# schema="information_schema")
key_constraints = pg_key_constraints
, ',\n')
def __str__(self):
- if self.schema is None:
- return self.name
- else:
- return self.schema + "." + self.name
+ return _get_table_key(self.name, self.schema)
def reload_values(self, *args):
"""clears out the columns and other properties of this Table, and reloads them from the
self.indexes[index.name] = index
def _set_parent(self, metadata):
- metadata.tables[self.name] = self
+ metadata.tables[_get_table_key(self.name, self.schema)] = self
self._metadata = metadata
def accept_schema_visitor(self, visitor):
"""traverses the given visitor across the Column objects inside this Table,
import sqlalchemy.ansisql as ansisql
-import sqlalchemy.databases.postgres as postgres
from sqlalchemy import *
-from sqlalchemy.exceptions import *
+from sqlalchemy.exceptions import NoSuchTableError
from testbase import PersistTest
import testbase
-import unittest, re
+import unittest, re, StringIO
class ReflectionTest(PersistTest):
def testbasic(self):
metadata.drop_all(engine=testbase.db)
self.assertEqual( testbase.db.has_table('items'), False )
-
-
+class SchemaTest(PersistTest):
+ # this test should really be in the sql tests somewhere, not engine
+ def testiteration(self):
+ metadata = MetaData()
+ table1 = Table('table1', metadata,
+ Column('col1', Integer, primary_key=True),
+ schema='someschema')
+ table2 = Table('table2', metadata,
+ Column('col1', Integer, primary_key=True),
+ Column('col2', Integer, ForeignKey('someschema.table1.col1')),
+ schema='someschema')
+ # insure this doesnt crash
+ print [t for t in metadata.table_iterator()]
+ buf = StringIO.StringIO()
+ def foo(s, p):
+ buf.write(s)
+ gen = testbase.db.dialect.schemagenerator(testbase.db.engine, foo)
+ table1.accept_schema_visitor(gen)
+ table2.accept_schema_visitor(gen)
+ buf = buf.getvalue()
+ assert buf.index("CREATE TABLE someschema.table1") > -1
+ assert buf.index("CREATE TABLE someschema.table2") > -1
+
+
+
+
if __name__ == "__main__":
testbase.main()