Commits

Mike Bayer committed ab080cc

- query.count() emits "count(*)" instead of
"count(1)". [ticket:2162]
- another test that should be excluded from "low-connections"

  • Participants
  • Parent commits 38baf8d

Comments (0)

Files changed (5)

     fixed up some of the error messages tailored
     in [ticket:2069]
 
+  - query.count() emits "count(*)" instead of 
+    "count(1)".  [ticket:2162]
+
   - Fine tuning of Query clause adaptation when
     from_self(), union(), or other "select from
     myself" operation, such that plain SQL expression

lib/sqlalchemy/orm/query.py

             session.query(func.count(distinct(User.name)))
             
         """
-        col = sql.func.count(sql.literal_column('1'))
+        col = sql.func.count(sql.literal_column('*'))
         return self.from_self(col).scalar()
 
     def delete(self, synchronize_session='evaluate'):

test/engine/test_transaction.py

 
 
 class ForUpdateTest(fixtures.TestBase):
+    __requires__ = 'ad_hoc_engines',
 
     @classmethod
     def setup_class(cls):

test/lib/assertsql.py

                 equivalent = False
         else:
             params = {}
+            all_params = {}
+            all_received = []
         self._result = equivalent
         if not self._result:
             print 'Testing for compiled statement %r partial params '\

test/orm/test_query.py

 from sqlalchemy.engine import default
 from sqlalchemy.orm import *
 from sqlalchemy.orm import attributes
-
+from test.lib.assertsql import CompiledSQL
 from test.lib.testing import eq_
 
 import sqlalchemy as sa
 
         eq_(s.query(User).filter(users.c.name.endswith('ed')).count(), 2)
 
+    def test_count_char(self):
+        User = self.classes.User
+        s = create_session()
+        # '*' is favored here as the most common character,
+        # it is reported that Informix doesn't like count(1),
+        # rumors about Oracle preferring count(1) don't appear 
+        # to be well founded.
+        self.assert_sql_execution(
+                testing.db,
+                s.query(User).count,
+                CompiledSQL(
+                    "SELECT count(*) AS count_1 FROM "
+                    "(SELECT users.id AS users_id, users.name "
+                    "AS users_name FROM users) AS anon_1",
+                    {} 
+                )
+        )
+
     def test_multiple_entity(self):
         User, Address = self.classes.User, self.classes.Address