diff options
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/sql/schema.py | 9 | ||||
| -rw-r--r-- | lib/sqlalchemy/util/langhelpers.py | 14 |
2 files changed, 15 insertions, 8 deletions
diff --git a/lib/sqlalchemy/sql/schema.py b/lib/sqlalchemy/sql/schema.py index a9d5a69b1..2614c08c8 100644 --- a/lib/sqlalchemy/sql/schema.py +++ b/lib/sqlalchemy/sql/schema.py @@ -27,6 +27,7 @@ Since these objects are part of the SQL expression language, they are usable as components in SQL expressions. """ +from __future__ import absolute_import import inspect from .. import exc, util, event, inspection @@ -41,6 +42,7 @@ from .selectable import TableClause import collections import sqlalchemy from . import ddl +import types RETAIN_SCHEMA = util.symbol('retain_schema') @@ -1844,7 +1846,12 @@ class ColumnDefault(DefaultGenerator): on everyone. """ - if inspect.isfunction(fn) or inspect.ismethod(fn): + # TODO: why aren't we using a util.langhelpers function + # for this? e.g. get_callable_argspec + + if isinstance(fn, (types.BuiltinMethodType, types.BuiltinFunctionType)): + return lambda ctx: fn() + elif inspect.isfunction(fn) or inspect.ismethod(fn): inspectable = fn elif inspect.isclass(fn): inspectable = fn.__init__ diff --git a/lib/sqlalchemy/util/langhelpers.py b/lib/sqlalchemy/util/langhelpers.py index 82e37ce99..94ddb242c 100644 --- a/lib/sqlalchemy/util/langhelpers.py +++ b/lib/sqlalchemy/util/langhelpers.py @@ -362,15 +362,15 @@ def format_argspec_init(method, grouped=True): other unreflectable (usually C) -> (self, *args, **kwargs) """ - try: - return format_argspec_plus(method, grouped=grouped) - except TypeError: - if method is object.__init__: - args = grouped and '(self)' or 'self' - else: + if method is object.__init__: + args = grouped and '(self)' or 'self' + else: + try: + return format_argspec_plus(method, grouped=grouped) + except TypeError: args = (grouped and '(self, *args, **kwargs)' or 'self, *args, **kwargs') - return dict(self_arg='self', args=args, apply_pos=args, apply_kw=args) + return dict(self_arg='self', args=args, apply_pos=args, apply_kw=args) def getargspec_init(method): |
