summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-01-17 20:32:45 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2010-01-17 20:32:45 +0000
commit2b1937a31e5b5d8de56f266ec7692a3d0dd90976 (patch)
tree945c6b38c7dca2c7dd65bcd9fd2af2beae553286 /lib/sqlalchemy
parent15bc27bfb7d881a1832f098da79e2407f7479dcd (diff)
downloadsqlalchemy-2b1937a31e5b5d8de56f266ec7692a3d0dd90976.tar.gz
- reorganized and re-documented Oracle schema tests to assume
test user has DBA privs, and all objects can be created /dropped. - added ORDER BY to oracle column listing - Oracle all_tables always limits to current user if schema not given. - views reflect - added documentation + a unit test for this. - Table(autoload) with no bind produces an error message specific to the fact that autoload_with should be the first option to try.
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/dialects/oracle/base.py21
-rw-r--r--lib/sqlalchemy/schema.py20
2 files changed, 22 insertions, 19 deletions
diff --git a/lib/sqlalchemy/dialects/oracle/base.py b/lib/sqlalchemy/dialects/oracle/base.py
index ca78a19a8..3cfdf828b 100644
--- a/lib/sqlalchemy/dialects/oracle/base.py
+++ b/lib/sqlalchemy/dialects/oracle/base.py
@@ -549,17 +549,13 @@ class OracleDialect(default.DefaultDialect):
def table_names(self, connection, schema):
# note that table_names() isnt loading DBLINKed or synonym'ed tables
if schema is None:
- cursor = connection.execute(
- "SELECT table_name FROM all_tables "
- "WHERE nvl(tablespace_name, 'no tablespace') NOT IN ('SYSTEM', 'SYSAUX') "
- "AND IOT_NAME IS NULL")
- else:
- s = sql.text(
- "SELECT table_name FROM all_tables "
- "WHERE nvl(tablespace_name, 'no tablespace') NOT IN ('SYSTEM', 'SYSAUX') "
- "AND OWNER = :owner "
- "AND IOT_NAME IS NULL")
- cursor = connection.execute(s, owner=self.denormalize_name(schema))
+ schema = self.default_schema_name
+ s = sql.text(
+ "SELECT table_name FROM all_tables "
+ "WHERE nvl(tablespace_name, 'no tablespace') NOT IN ('SYSTEM', 'SYSAUX') "
+ "AND OWNER = :owner "
+ "AND IOT_NAME IS NULL")
+ cursor = connection.execute(s, owner=self.denormalize_name(schema))
return [self.normalize_name(row[0]) for row in cursor]
def _resolve_synonym(self, connection, desired_owner=None, desired_synonym=None, desired_table=None):
@@ -660,7 +656,8 @@ class OracleDialect(default.DefaultDialect):
c = connection.execute(sql.text(
"SELECT column_name, data_type, data_length, data_precision, data_scale, "
"nullable, data_default FROM ALL_TAB_COLUMNS%(dblink)s "
- "WHERE table_name = :table_name AND owner = :owner" % {'dblink': dblink}),
+ "WHERE table_name = :table_name AND owner = :owner "
+ "ORDER BY column_id" % {'dblink': dblink}),
table_name=table_name, owner=schema)
for row in c:
diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py
index e40b6f592..f2737ecde 100644
--- a/lib/sqlalchemy/schema.py
+++ b/lib/sqlalchemy/schema.py
@@ -250,7 +250,12 @@ class Table(SchemaItem, expression.TableClause):
if autoload_with:
autoload_with.reflecttable(self, include_columns=include_columns)
else:
- _bind_or_error(metadata).reflecttable(self, include_columns=include_columns)
+ _bind_or_error(metadata, msg="No engine is bound to this Table's MetaData. "
+ "Pass an engine to the Table via "
+ "autoload_with=<someengine>, "
+ "or associate the MetaData with an engine via "
+ "metadata.bind=<someengine>").\
+ reflecttable(self, include_columns=include_columns)
# initialize all the column, etc. objects. done after reflection to
# allow user-overrides
@@ -2340,7 +2345,7 @@ class DropConstraint(_CreateDropBase):
super(DropConstraint, self).__init__(element, **kw)
element._create_rule = lambda compiler: False
-def _bind_or_error(schemaitem):
+def _bind_or_error(schemaitem, msg=None):
bind = schemaitem.bind
if not bind:
name = schemaitem.__class__.__name__
@@ -2354,11 +2359,12 @@ def _bind_or_error(schemaitem):
bindable = "the %s's .bind" % name
else:
bindable = "this %s's .metadata.bind" % name
-
- msg = ('The %s is not bound to an Engine or Connection. '
- 'Execution can not proceed without a database to execute '
- 'against. Either execute with an explicit connection or '
- 'assign %s to enable implicit execution.') % (item, bindable)
+
+ if msg is None:
+ msg = ('The %s is not bound to an Engine or Connection. '
+ 'Execution can not proceed without a database to execute '
+ 'against. Either execute with an explicit connection or '
+ 'assign %s to enable implicit execution.') % (item, bindable)
raise exc.UnboundExecutionError(msg)
return bind