mirror of
https://github.com/sqlalchemy/sqlalchemy.git
synced 2026-05-27 19:15:05 -04:00
20cdc64588
become an externally usable package but still remains within the main sqlalchemy parent package. in this system, we use kind of an ugly hack to get the noseplugin imported outside of the "sqlalchemy" package, while still making it available within sqlalchemy for usage by third party libraries.
63 lines
1.8 KiB
Python
63 lines
1.8 KiB
Python
from sqlalchemy import *
|
|
from sqlalchemy.testing import *
|
|
from sqlalchemy.engine import default
|
|
|
|
class CompileTest(fixtures.TestBase, AssertsExecutionResults):
|
|
__requires__ = 'cpython',
|
|
|
|
@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)))
|
|
|
|
# do a "compile" ahead of time to load
|
|
# deferred imports
|
|
t1.insert().compile()
|
|
|
|
# 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 import types
|
|
for t in types._type_map.values():
|
|
t._type_affinity
|
|
|
|
cls.dialect = default.DefaultDialect()
|
|
|
|
@profiling.function_call_count()
|
|
def test_insert(self):
|
|
t1.insert().compile(dialect=self.dialect)
|
|
|
|
@profiling.function_call_count()
|
|
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()
|
|
def go():
|
|
s = select([t1], t1.c.c2 == t2.c.c1)
|
|
s.compile(dialect=self.dialect)
|
|
go() |