|
35 | 35 | from pytz import timezone |
36 | 36 | from sedate import utcnow |
37 | 37 | from sqlalchemy import ( |
38 | | - and_, event, func, inspect, select, text, ForeignKey, Integer |
| 38 | + and_, func, inspect, select, text, ForeignKey, Integer |
39 | 39 | ) |
40 | 40 | from sqlalchemy.exc import OperationalError |
41 | 41 | from sqlalchemy.ext.mutable import MutableDict |
@@ -178,37 +178,6 @@ def schema_tables(schema: str) -> set[str]: |
178 | 178 | mgr.dispose() |
179 | 179 |
|
180 | 180 |
|
181 | | -def test_schema_init_query_count(postgres_dsn: str) -> None: |
182 | | - class Base(DeclarativeBase, ModelBase): |
183 | | - registry = registry() |
184 | | - |
185 | | - # create enough tables so the difference between O(1) and O(N) is clear |
186 | | - for i in range(20): |
187 | | - type(f'Table{i}', (Base,), { |
188 | | - '__tablename__': f'table_{i}', |
189 | | - 'id': mapped_column(Integer, primary_key=True), |
190 | | - }) |
191 | | - |
192 | | - mgr = SessionManager(postgres_dsn, Base) |
193 | | - |
194 | | - query_count = 0 |
195 | | - |
196 | | - def count_queries(*args: Any, **kwargs: Any) -> None: |
197 | | - nonlocal query_count |
198 | | - query_count += 1 |
199 | | - |
200 | | - event.listen(mgr.engine, 'before_cursor_execute', count_queries) |
201 | | - mgr.ensure_schema_exists('test_query_count') |
202 | | - |
203 | | - table_count = len(Base.metadata.sorted_tables) |
204 | | - # O(1) implementation: fixed overhead + 1 get_table_names call |
205 | | - # O(N) implementation: fixed overhead + 1 has_table call per table |
206 | | - print('query count:', query_count, 'table count:', table_count) |
207 | | - assert query_count < 2 * table_count |
208 | | - |
209 | | - mgr.dispose() |
210 | | - |
211 | | - |
212 | 181 | def test_schema_bound_session(postgres_dsn: str) -> None: |
213 | 182 | class Base(DeclarativeBase, ModelBase): |
214 | 183 | registry = registry() |
|
0 commit comments