summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/functions.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-08-24 16:14:47 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2012-08-24 16:14:47 -0400
commit2c2c6a3fe8e4ee29026ba7016e3a5d5b2850ec6b (patch)
treef60ac600f584a33a9e6c16deaae48eccd4971fa5 /lib/sqlalchemy/sql/functions.py
parent17f9bc5735b021201c1800adc2236b3fe67262b2 (diff)
downloadsqlalchemy-2c2c6a3fe8e4ee29026ba7016e3a5d5b2850ec6b.tar.gz
- correct the argument signature for GenericFunction to be more predictable
Diffstat (limited to 'lib/sqlalchemy/sql/functions.py')
-rw-r--r--lib/sqlalchemy/sql/functions.py21
1 files changed, 8 insertions, 13 deletions
diff --git a/lib/sqlalchemy/sql/functions.py b/lib/sqlalchemy/sql/functions.py
index 79f1bcde2..fe64764b7 100644
--- a/lib/sqlalchemy/sql/functions.py
+++ b/lib/sqlalchemy/sql/functions.py
@@ -6,7 +6,7 @@
from .. import types as sqltypes, schema
from .expression import (
- ClauseList, Function, _literal_as_binds, text, _type_from_args
+ ClauseList, Function, _literal_as_binds, literal_column, _type_from_args
)
from . import operators
from .visitors import VisitableType
@@ -87,15 +87,14 @@ class GenericFunction(Function):
__metaclass__ = _GenericMeta
coerce_arguments = True
- def __init__(self, type_=None, args=(), **kwargs):
- args = [_literal_as_binds(c) for c in args]
+ def __init__(self, *args, **kwargs):
self.packagenames = []
self._bind = kwargs.get('bind', None)
self.clause_expr = ClauseList(
operator=operators.comma_op,
group_contents=True, *args).self_group()
self.type = sqltypes.to_instance(
- type_ or getattr(self, 'type', None))
+ kwargs.pop("type_", None) or getattr(self, 'type', None))
class next_value(GenericFunction):
@@ -130,7 +129,7 @@ class ReturnTypeFromArgs(GenericFunction):
def __init__(self, *args, **kwargs):
kwargs.setdefault('type_', _type_from_args(args))
- GenericFunction.__init__(self, args=args, **kwargs)
+ GenericFunction.__init__(self, *args, **kwargs)
class coalesce(ReturnTypeFromArgs):
pass
@@ -150,19 +149,15 @@ class now(GenericFunction):
class concat(GenericFunction):
type = sqltypes.String
- def __init__(self, *args, **kwargs):
- GenericFunction.__init__(self, args=args, **kwargs)
class char_length(GenericFunction):
type = sqltypes.Integer
def __init__(self, arg, **kwargs):
- GenericFunction.__init__(self, args=[arg], **kwargs)
+ GenericFunction.__init__(self, arg, **kwargs)
class random(GenericFunction):
- def __init__(self, *args, **kwargs):
- kwargs.setdefault('type_', None)
- GenericFunction.__init__(self, args=args, **kwargs)
+ pass
class count(GenericFunction):
"""The ANSI COUNT aggregate function. With no arguments, emits COUNT \*."""
@@ -171,8 +166,8 @@ class count(GenericFunction):
def __init__(self, expression=None, **kwargs):
if expression is None:
- expression = text('*')
- GenericFunction.__init__(self, args=(expression,), **kwargs)
+ expression = literal_column('*')
+ GenericFunction.__init__(self, expression, **kwargs)
class current_date(AnsiFunction):
type = sqltypes.Date