From 43d476ce60339f3369847191988b96b3f3665f44 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 18 Nov 2007 02:44:15 +0000 Subject: [PATCH] - oracle will now reflect "DATE" as an OracleDateTime column, not OracleDate - added awareness of schema name in oracle table_names() function, fixes metadata.reflect(schema='someschema') [ticket:847] --- CHANGES | 8 +++++++- lib/sqlalchemy/databases/oracle.py | 19 ++++++++++++++++--- test/engine/reflection.py | 4 ++-- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/CHANGES b/CHANGES index 1f3416d146..ff0462814e 100644 --- a/CHANGES +++ b/CHANGES @@ -157,9 +157,15 @@ CHANGES could get polluted by certain generative calls [ticket:852] - dialects - + - Added experimental support for MaxDB (versions >= 7.6.03.007 only). + - oracle will now reflect "DATE" as an OracleDateTime column, not + OracleDate + + - added awareness of schema name in oracle table_names() function, + fixes metadata.reflect(schema='someschema') [ticket:847] + - sqlite will reflect "DECIMAL" as a numeric column. - Made access dao detection more reliable [ticket:828] diff --git a/lib/sqlalchemy/databases/oracle.py b/lib/sqlalchemy/databases/oracle.py index 015701e901..71c82bfd86 100644 --- a/lib/sqlalchemy/databases/oracle.py +++ b/lib/sqlalchemy/databases/oracle.py @@ -177,7 +177,7 @@ colspecs = { ischema_names = { 'VARCHAR2' : OracleString, - 'DATE' : OracleDate, + 'DATE' : OracleDateTime, 'DATETIME' : OracleDateTime, 'NUMBER' : OracleNumeric, 'BLOB' : OracleBinary, @@ -442,10 +442,23 @@ class OracleDialect(default.DefaultDialect): else: return name.encode(self.encoding) + def get_default_schema_name(self,connection): + try: + return self._default_schema_name + except AttributeError: + name = self._default_schema_name = \ + connection.execute('SELECT USER FROM DUAL').scalar() + return name + def table_names(self, connection, schema): # note that table_names() isnt loading DBLINKed or synonym'ed tables - s = "select table_name from all_tables where tablespace_name NOT IN ('SYSTEM', 'SYSAUX')" - return [self._normalize_name(row[0]) for row in connection.execute(s)] + if schema is None: + s = "select table_name from all_tables where tablespace_name NOT IN ('SYSTEM', 'SYSAUX')" + cursor = connection.execute(s) + else: + s = "select table_name from all_tables where tablespace_name NOT IN ('SYSTEM','SYSAUX') AND OWNER = :owner" + cursor = connection.execute(s,{'owner':self._denormalize_name(schema)}) + return [self._normalize_name(row[0]) for row in cursor] def reflecttable(self, connection, table, include_columns): preparer = self.identifier_preparer diff --git a/test/engine/reflection.py b/test/engine/reflection.py index 534cdd2c1b..cbc221e935 100644 --- a/test/engine/reflection.py +++ b/test/engine/reflection.py @@ -186,7 +186,7 @@ class ReflectionTest(PersistTest): def test_unknown_types(self): meta = MetaData(testbase.db) t = Table("test", meta, - Column('foo', String(30))) + Column('foo', DateTime)) import sys dialect_module = sys.modules[testbase.db.dialect.__module__] @@ -689,7 +689,7 @@ class CreateDropTest(PersistTest): metadata.drop_all(bind=testbase.db) class UnicodeTest(PersistTest): - @testing.unsupported('sybase', 'maxdb') + @testing.unsupported('sybase', 'maxdb', 'oracle') def test_basic(self): try: # the 'convert_unicode' should not get in the way of the reflection -- 2.47.2