Mike Bayer avatar Mike Bayer committed ae2340a

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

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 


           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


         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.name, 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([table1.c.name]).scalar() + literal('x')]), "SELECT (SELECT mytable.name FROM mytable) || :literal")
+        self.runtest(select([select([table1.c.name]).as_scalar() + literal('x')]), "SELECT (SELECT mytable.name FROM mytable) || :literal")
         self.runtest(select([s > literal(8)]), "SELECT (SELECT mytable.myid FROM mytable) > :literal")
         self.runtest(select([select([table1.c.name]).label('foo')]), "SELECT (SELECT mytable.name 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.id, places.c.nm, zips.c.zipcode, func.latlondist(qlat, qlng).label('dist')],
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.