mirror of
https://github.com/sqlalchemy/sqlalchemy.git
synced 2026-05-20 07:32:05 -04:00
91f376692d
Several weeks of using the future_select() construct has led to the proposal there be just one select() construct again which features the new join() method, and otherwise accepts both the 1.x and 2.x argument styles. This would make migration simpler and reduce confusion. However, confusion may be increased by the fact that select().join() is different Current thinking is we may be better off with a few hard behavioral changes to old and relatively unknown APIs rather than trying to play both sides within two extremely similar but subtly different APIs. At the moment, the .join() thing seems to be the only behavioral change that occurs without the user taking any explicit steps. Session.execute() will still behave the old way as we are adding a future flag. This change also adds the "future" flag to Session() and session.execute(), so that interpretation of the incoming statement, as well as that the new style result is returned, does not occur for existing applications unless they add the use of this flag. The change in general is moving the "removed in 2.0" system further along where we want the test suite to fully pass even if the SQLALCHEMY_WARN_20 flag is set. Get many tests to pass when SQLALCHEMY_WARN_20 is set; this should be ongoing after this patch merges. Improve the RemovedIn20 warning; these are all deprecated "since" 1.4, so ensure that's what the messages read. Make sure the inforamtion link is on all warnings. Add deprecation warnings for parameters present and add warnings to all FromClause.select() types of methods. Fixes: #5379 Fixes: #5284 Change-Id: I765a0b912b3dcd0e995426427d8bb7997cbffd51 References: #5159
99 lines
2.7 KiB
Python
99 lines
2.7 KiB
Python
from sqlalchemy import Column
|
|
from sqlalchemy import Integer
|
|
from sqlalchemy import MetaData
|
|
from sqlalchemy import select
|
|
from sqlalchemy import String
|
|
from sqlalchemy import Table
|
|
from sqlalchemy.engine import default
|
|
from sqlalchemy.testing import AssertsExecutionResults
|
|
from sqlalchemy.testing import fixtures
|
|
from sqlalchemy.testing import profiling
|
|
|
|
|
|
t1 = t2 = None
|
|
|
|
|
|
class CompileTest(fixtures.TestBase, AssertsExecutionResults):
|
|
__requires__ = ("cpython",)
|
|
__backend__ = True
|
|
|
|
@classmethod
|
|
def setup_class(cls):
|
|
|
|
global t1, t2, metadata
|
|
metadata = MetaData()
|
|
t1 = Table(
|
|
"t1",
|
|
metadata,
|
|
Column("c1", Integer, primary_key=True),
|
|
Column("c2", String(30)),
|
|
)
|
|
|
|
t2 = Table(
|
|
"t2",
|
|
metadata,
|
|
Column("c1", Integer, primary_key=True),
|
|
Column("c2", String(30)),
|
|
)
|
|
|
|
cls.dialect = default.DefaultDialect()
|
|
|
|
# do a "compile" ahead of time to load
|
|
# deferred imports, use the dialect to pre-load
|
|
# dialect-level types
|
|
t1.insert().compile(dialect=cls.dialect)
|
|
|
|
# go through all the TypeEngine
|
|
# objects in use and pre-load their _type_affinity
|
|
# entries.
|
|
for t in (t1, t2):
|
|
for c in t.c:
|
|
c.type._type_affinity
|
|
from sqlalchemy.sql import sqltypes
|
|
|
|
for t in list(sqltypes._type_map.values()):
|
|
t._type_affinity
|
|
|
|
@profiling.function_call_count()
|
|
def test_insert(self):
|
|
t1.insert().compile(dialect=self.dialect)
|
|
|
|
@profiling.function_call_count(variance=0.15)
|
|
def test_update(self):
|
|
t1.update().compile(dialect=self.dialect)
|
|
|
|
def test_update_whereclause(self):
|
|
t1.update().where(t1.c.c2 == 12).compile(dialect=self.dialect)
|
|
|
|
@profiling.function_call_count()
|
|
def go():
|
|
t1.update().where(t1.c.c2 == 12).compile(dialect=self.dialect)
|
|
|
|
go()
|
|
|
|
def test_select(self):
|
|
# give some of the cached type values
|
|
# a chance to warm up
|
|
s = select([t1], t1.c.c2 == t2.c.c1)
|
|
s.compile(dialect=self.dialect)
|
|
|
|
@profiling.function_call_count(variance=0.15, warmup=1)
|
|
def go():
|
|
s = select([t1], t1.c.c2 == t2.c.c1)
|
|
s.compile(dialect=self.dialect)
|
|
|
|
go()
|
|
|
|
def test_select_labels(self):
|
|
# give some of the cached type values
|
|
# a chance to warm up
|
|
s = select([t1], t1.c.c2 == t2.c.c1).apply_labels()
|
|
s.compile(dialect=self.dialect)
|
|
|
|
@profiling.function_call_count(variance=0.15, warmup=1)
|
|
def go():
|
|
s = select([t1], t1.c.c2 == t2.c.c1).apply_labels()
|
|
s.compile(dialect=self.dialect)
|
|
|
|
go()
|