return OracleExecutionContext(self, *args, **kwargs)
def has_table(self, connection, table_name, schema=None):
- cursor = connection.execute("""select table_name from all_tables where table_name=:name""", {'name':self._denormalize_name(table_name)})
+ if not schema:
+ schema = self.get_default_schema_name(connection)
+ cursor = connection.execute("""select table_name from all_tables where table_name=:name and owner=:schema_name""", {'name':self._denormalize_name(table_name), 'schema_name':self._denormalize_name(schema)})
return bool( cursor.fetchone() is not None )
def has_sequence(self, connection, sequence_name):
"ON addresses.address_type_id = address_types_1.id WHERE addresses.user_id = :user_id_1 ORDER BY addresses.rowid, "
"address_types.rowid")
-class SchemaReflectionTest(TestBase, AssertsCompiledSQL):
+class MultiSchemaTest(TestBase, AssertsCompiledSQL):
"""instructions:
1. create a user 'ed' in the oracle database.
__only_on__ = 'oracle'
+ def test_create_same_names_explicit_schema(self):
+ schema = testing.db.dialect.get_default_schema_name(testing.db.connect())
+ meta = MetaData(testing.db)
+ parent = Table('parent', meta,
+ Column('pid', Integer, primary_key=True),
+ schema=schema
+ )
+ child = Table('child', meta,
+ Column('cid', Integer, primary_key=True),
+ Column('pid', Integer, ForeignKey('scott.parent.pid')),
+ schema=schema
+ )
+ meta.create_all()
+ try:
+ parent.insert().execute({'pid':1})
+ child.insert().execute({'cid':1, 'pid':1})
+ self.assertEquals(child.select().execute().fetchall(), [(1, 1)])
+ finally:
+ meta.drop_all()
+
+ def test_create_same_names_implicit_schema(self):
+ meta = MetaData(testing.db)
+ parent = Table('parent', meta,
+ Column('pid', Integer, primary_key=True),
+ )
+ child = Table('child', meta,
+ Column('cid', Integer, primary_key=True),
+ Column('pid', Integer, ForeignKey('parent.pid')),
+ )
+ meta.create_all()
+ try:
+ parent.insert().execute({'pid':1})
+ child.insert().execute({'cid':1, 'pid':1})
+ self.assertEquals(child.select().execute().fetchall(), [(1, 1)])
+ finally:
+ meta.drop_all()
+
+
def test_reflect_alt_owner_explicit(self):
meta = MetaData(testing.db)
parent = Table('parent', meta, autoload=True, schema='ed')