From c7d04beeac6ad54d638afb01783dee2d769aef9d Mon Sep 17 00:00:00 2001 From: "Martin J. Hsu" Date: Fri, 25 Sep 2015 16:15:28 +0800 Subject: - wrap ColumnDefault empty arg callables like functools.wraps, setting __name__, __doc__, and __module__ --- lib/sqlalchemy/sql/schema.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/sqlalchemy/sql') diff --git a/lib/sqlalchemy/sql/schema.py b/lib/sqlalchemy/sql/schema.py index 137208584..0c433d16e 100644 --- a/lib/sqlalchemy/sql/schema.py +++ b/lib/sqlalchemy/sql/schema.py @@ -1981,13 +1981,14 @@ class ColumnDefault(DefaultGenerator): try: argspec = util.get_callable_argspec(fn, no_self=True) except TypeError: - return lambda ctx: fn() + return util.wrap_callable(fn) defaulted = argspec[3] is not None and len(argspec[3]) or 0 positionals = len(argspec[0]) - defaulted if positionals == 0: - return lambda ctx: fn() + return util.wrap_callable(fn) + elif positionals == 1: return fn else: -- cgit v1.2.1 From e31211c578854d63128a30c036e40eee5c43edc7 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 29 Oct 2015 14:25:58 -0400 Subject: - convert wrap_callable() to a general purpose update_wrapper-like function; the caller still passes in the "wrapper" - move tests for wrap_callable() to be generic util tests - changelog for pullreq github:204 --- lib/sqlalchemy/sql/schema.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/sqlalchemy/sql') diff --git a/lib/sqlalchemy/sql/schema.py b/lib/sqlalchemy/sql/schema.py index 0c433d16e..a88203e84 100644 --- a/lib/sqlalchemy/sql/schema.py +++ b/lib/sqlalchemy/sql/schema.py @@ -1981,13 +1981,13 @@ class ColumnDefault(DefaultGenerator): try: argspec = util.get_callable_argspec(fn, no_self=True) except TypeError: - return util.wrap_callable(fn) + return util.wrap_callable(lambda ctx: fn(), fn) defaulted = argspec[3] is not None and len(argspec[3]) or 0 positionals = len(argspec[0]) - defaulted if positionals == 0: - return util.wrap_callable(fn) + return util.wrap_callable(lambda ctx: fn(), fn) elif positionals == 1: return fn -- cgit v1.2.1