summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/util.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2007-07-14 21:57:51 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2007-07-14 21:57:51 +0000
commit8889d2c1bc7c527271909c0896e5d053c6aa369e (patch)
treeddc0ff9785eaa62ae5dbd6fadf659f24e859cf39 /lib/sqlalchemy/util.py
parent44289e375bf0b421dac6eddb8cb072360fe0ad31 (diff)
downloadsqlalchemy-8889d2c1bc7c527271909c0896e5d053c6aa369e.tar.gz
- improved ability to get the "correct" and most minimal set of primary key
columns from a join, equating foreign keys and otherwise equated columns. this is also mostly to help inheritance scenarios formulate the best choice of primary key columns. [ticket:185] - added 'bind' argument to Sequence.create()/drop(), ColumnDefault.execute()
Diffstat (limited to 'lib/sqlalchemy/util.py')
-rw-r--r--lib/sqlalchemy/util.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/sqlalchemy/util.py b/lib/sqlalchemy/util.py
index c827f1e7d..b47822d61 100644
--- a/lib/sqlalchemy/util.py
+++ b/lib/sqlalchemy/util.py
@@ -10,6 +10,7 @@ except ImportError:
import dummy_thread as thread
import dummy_threading as threading
+from sqlalchemy import exceptions
import md5
import sys
import warnings
@@ -128,7 +129,16 @@ def duck_type_collection(col, default=None):
return dict
else:
return default
-
+
+def assert_arg_type(arg, argtype, name):
+ if isinstance(arg, argtype):
+ return arg
+ else:
+ if isinstance(argtype, tuple):
+ raise exceptions.ArgumentError("Argument '%s' is expected to be one of type %s, got '%s'" % (name, ' or '.join(["'%s'" % str(a) for a in argtype]), str(type(arg))))
+ else:
+ raise exceptions.ArgumentError("Argument '%s' is expected to be of type '%s', got '%s'" % (name, str(argtype), str(type(arg))))
+
def warn_exception(func):
"""executes the given function, catches all exceptions and converts to a warning."""
try: