summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/expression.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2011-06-02 03:09:08 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2011-06-02 03:09:08 -0400
commit1dcf33e71280698007af718a2404034ef51dd1c7 (patch)
tree69c782bd69c4833213ec12229c35440cfcb8536c /lib/sqlalchemy/sql/expression.py
parentdf21626ef065e80adfb39d3e48edc16f7c62ab0c (diff)
downloadsqlalchemy-1dcf33e71280698007af718a2404034ef51dd1c7.tar.gz
fix some tests
Diffstat (limited to 'lib/sqlalchemy/sql/expression.py')
-rw-r--r--lib/sqlalchemy/sql/expression.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py
index 47f19806a..38eb71da8 100644
--- a/lib/sqlalchemy/sql/expression.py
+++ b/lib/sqlalchemy/sql/expression.py
@@ -1144,6 +1144,12 @@ func = _FunctionGenerator()
>>> print func.count(1)
count(:param_1)
+ The element is a column-oriented SQL element like any other, and is
+ used in that way::
+
+ >>> print select([func.count(table.c.id)])
+ SELECT count(sometable.id) FROM sometable
+
Any name can be given to ``func``. If the function name is unknown to
SQLAlchemy, it will be rendered exactly as is. For common SQL functions
which SQLAlchemy is aware of, the name may be interpreted as a *generic
@@ -1171,7 +1177,16 @@ func = _FunctionGenerator()
This object meets the "column" interface, including comparison and labeling
functions. The object can also be passed the :meth:`~.Connectable.execute`
method of a :class:`.Connection` or :class:`.Engine`, where it will be
- wrapped inside of a SELECT statement first.
+ wrapped inside of a SELECT statement first::
+
+ print connection.execute(func.current_timestamp()).scalar()
+
+ A function can also be "bound" to a :class:`.Engine` or :class:`.Connection`
+ using the ``bind`` keyword argument, providing an execute() as well
+ as a scalar() method::
+
+ myfunc = func.current_timestamp(bind=some_engine)
+ print myfunc.scalar()
Functions which are interpreted as "generic" functions know how to
calculate their return type automatically. For a listing of known generic