]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Note to self: save buffers before committing.
authorJason Kirtland <jek@discorporate.us>
Thu, 11 Sep 2008 18:44:36 +0000 (18:44 +0000)
committerJason Kirtland <jek@discorporate.us>
Thu, 11 Sep 2008 18:44:36 +0000 (18:44 +0000)
lib/sqlalchemy/orm/query.py

index cb1773e5ae6d289209ae7d6111da5c92fdd4c94c..c9f29e6be6e01fe3917d8db8f49bc4d7f76be309 100644 (file)
@@ -1038,8 +1038,20 @@ class Query(object):
                 "Multiple rows were found for one()")
 
     def scalar(self):
-        """Return """
+        """Return the first element of the first result or None.
 
+          >>> session.query(Item).scalar()
+          <Item>
+          >>> session.query(Item.id).scalar()
+          1
+          >>> session.query(Item.id, Item.name).scalar()
+          1
+          >>> session.query(func.count(Parent.id)).scalar()
+          20
+
+        This results in an execution of the underlying query.
+
+        """
         ret = list(self)[0]
         if not isinstance(ret, tuple):
             return ret