Deprecate FromClause.count() (pending for 1.1)

count() here is misleading in that it not only
counts from an arbitrary column in the table, it also
does not make accommodations for DISTINCT, JOIN, etc.
as the ORM-level function does.  Core should not be
attempting to provide a function like this.

Change-Id: I9916fc51ef744389a92c54660ab08e9695b8afc2
Fixes: #3724
This commit is contained in:
Mike Bayer
2016-06-13 15:18:13 -04:00
parent 33e2a0230e
commit e7ea2a4e19
5 changed files with 38 additions and 31 deletions
+2 -1
View File
@@ -774,7 +774,8 @@ class AutoIncrementTest(fixtures.TablesTest):
testing.db.execute(dataset_no_autoinc.insert())
eq_(
testing.db.scalar(dataset_no_autoinc.count()), 1
testing.db.scalar(
select([func.count('*')]).select_from(dataset_no_autoinc)), 1
)
-12
View File
@@ -21,18 +21,6 @@ from sqlalchemy import util
class MetaDataTest(fixtures.TestBase, ComparesTables):
def test_metadata_connect(self):
metadata = MetaData()
t1 = Table('table1', metadata,
Column('col1', Integer, primary_key=True),
Column('col2', String(20)))
metadata.bind = testing.db
metadata.create_all()
try:
assert t1.count().scalar() == 0
finally:
metadata.drop_all()
def test_metadata_contains(self):
metadata = MetaData()
t1 = Table('t1', metadata, Column('x', Integer))
+2 -2
View File
@@ -1247,8 +1247,8 @@ class BinaryTest(fixtures.TestBase, AssertsExecutionResults):
data = os.urandom(32)
binary_table.insert().execute(data=data)
eq_(
binary_table.select().where(binary_table.c.data == data).alias().
count().scalar(), 1)
select([func.count('*')]).select_from(binary_table).
where(binary_table.c.data == data).scalar(), 1)
@testing.requires.binary_literals
def test_literal_roundtrip(self):