Mike Bayer  committed ae2340a

renamed new scalar() method to as_scalar(), not deprecating normal ClauseElement.scalar()...

  • Participants
  • Parent commits 5039434
  • Branches rel_0_4

Comments (0)

Files changed (3)

     regarding "is subquery" and "correlation" pushed to SQL generation phase.
     select() elements are now *never* mutated by their enclosing containers
     or by any dialect's compilation process [ticket:52] [ticket:569]
+  - select(scalar=True) argument is deprecated; use select(..).as_scalar().
+    the resulting object obeys the full "column" interface and plays better
+    within expressions
   - result sets make a better attempt at matching the DBAPI types present
     in cursor.description to the TypeEngine objects defined by the dialect,
     which are then used for result-processing. Note this only takes effect 

File lib/sqlalchemy/

           will attempt to provide similar functionality.
-          deprecated.  use select(...).scalar() to create a "scalar column"
+          deprecated.  use select(...).as_scalar() to create a "scalar column"
           proxy for an existing Select object.
     scalar = kwargs.pop('scalar', False)
     s = Select(columns, whereclause=whereclause, from_obj=from_obj, **kwargs)
     if scalar:
-        return s.scalar()
+        return s.as_scalar()
         return s
         self.append_order_by(*util.to_list(order_by, []))
         self.append_group_by(*util.to_list(group_by, []))
-    def scalar(self):
+    def as_scalar(self):
         return _ScalarSelect(self)
     def label(self, name):
-        return self.scalar().label(name)
+        return self.as_scalar().label(name)
     def supports_execution(self):
         return True

File test/sql/

         s = select([table1.c.myid], scalar=True)
         self.runtest(select([table2, s]), "SELECT myothertable.otherid, myothertable.othername, (SELECT mytable.myid FROM mytable) FROM myothertable")
-        s = select([table1.c.myid]).correlate(None).scalar()
+        s = select([table1.c.myid]).correlate(None).as_scalar()
         self.runtest(select([table1, s]), "SELECT mytable.myid,, mytable.description, (SELECT mytable.myid FROM mytable) FROM mytable")
-        s = select([table1.c.myid]).scalar()
+        s = select([table1.c.myid]).as_scalar()
         self.runtest(select([table2, s]), "SELECT myothertable.otherid, myothertable.othername, (SELECT mytable.myid FROM mytable) FROM myothertable")
         # test expressions against scalar selects
         self.runtest(select([s - literal(8)]), "SELECT (SELECT mytable.myid FROM mytable) - :literal")
-        self.runtest(select([select([]).scalar() + literal('x')]), "SELECT (SELECT FROM mytable) || :literal")
+        self.runtest(select([select([]).as_scalar() + literal('x')]), "SELECT (SELECT FROM mytable) || :literal")
         self.runtest(select([s > literal(8)]), "SELECT (SELECT mytable.myid FROM mytable) > :literal")
         self.runtest(select([select([]).label('foo')]), "SELECT (SELECT FROM mytable) AS foo")
         zip = '12345'
-        qlat = select([zips.c.latitude], zips.c.zipcode == zip).correlate(None).scalar()
-        qlng = select([zips.c.longitude], zips.c.zipcode == zip).correlate(None).scalar()
+        qlat = select([zips.c.latitude], zips.c.zipcode == zip).correlate(None).as_scalar()
+        qlng = select([zips.c.longitude], zips.c.zipcode == zip).correlate(None).as_scalar()
         q = select([, places.c.nm, zips.c.zipcode, func.latlondist(qlat, qlng).label('dist')],