diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-06-13 15:18:13 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-06-14 11:48:04 -0400 |
| commit | f38f890849700ee1bf719a31275260e2da455bc3 (patch) | |
| tree | e5d8a958d853f05081e57045baa8c9806ad8f27a /test/sql | |
| parent | 7189d0bc82598c2d6dcbb55b054837416db2ee7d (diff) | |
| download | sqlalchemy-f38f890849700ee1bf719a31275260e2da455bc3.tar.gz | |
Deprecate FromClause.count()
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
Diffstat (limited to 'test/sql')
| -rw-r--r-- | test/sql/test_defaults.py | 3 | ||||
| -rw-r--r-- | test/sql/test_metadata.py | 12 | ||||
| -rw-r--r-- | test/sql/test_types.py | 4 |
3 files changed, 4 insertions, 15 deletions
diff --git a/test/sql/test_defaults.py b/test/sql/test_defaults.py index e21b21ab2..db19e145b 100644 --- a/test/sql/test_defaults.py +++ b/test/sql/test_defaults.py @@ -775,7 +775,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 ) diff --git a/test/sql/test_metadata.py b/test/sql/test_metadata.py index 344cfefa5..92d35e6e5 100644 --- a/test/sql/test_metadata.py +++ b/test/sql/test_metadata.py @@ -23,18 +23,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)) diff --git a/test/sql/test_types.py b/test/sql/test_types.py index 3d527b261..67d20871c 100644 --- a/test/sql/test_types.py +++ b/test/sql/test_types.py @@ -1477,8 +1477,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): |
