1
from sqlalchemy.engine import default
2
from sqlalchemy.testing import fixtures, AssertsExecutionResults, profiling
3
from sqlalchemy import MetaData, Table, Column, Integer, String, select
8
class CompileTest(fixtures.TestBase, AssertsExecutionResults):
9
__requires__ = 'cpython',
15
global t1, t2, metadata
17
t1 = Table('t1', metadata,
18
Column('c1', Integer, primary_key=True),
19
Column('c2', String(30)))
21
t2 = Table('t2', metadata,
22
Column('c1', Integer, primary_key=True),
23
Column('c2', String(30)))
25
# do a "compile" ahead of time to load
29
# go through all the TypeEngine
30
# objects in use and pre-load their _type_affinity
35
from sqlalchemy import types
36
for t in list(types._type_map.values()):
39
cls.dialect = default.DefaultDialect()
41
@profiling.function_call_count()
42
def test_insert(self):
43
t1.insert().compile(dialect=self.dialect)
45
@profiling.function_call_count(variance=.15)
46
def test_update(self):
47
t1.update().compile(dialect=self.dialect)
49
def test_update_whereclause(self):
50
t1.update().where(t1.c.c2 == 12).compile(dialect=self.dialect)
52
@profiling.function_call_count()
54
t1.update().where(t1.c.c2 == 12).compile(dialect=self.dialect)
57
def test_select(self):
58
# give some of the cached type values
60
s = select([t1], t1.c.c2 == t2.c.c1)
61
s.compile(dialect=self.dialect)
63
@profiling.function_call_count()
65
s = select([t1], t1.c.c2 == t2.c.c1)
66
s.compile(dialect=self.dialect)
69
def test_select_labels(self):
70
# give some of the cached type values
72
s = select([t1], t1.c.c2 == t2.c.c1).apply_labels()
73
s.compile(dialect=self.dialect)
75
@profiling.function_call_count()
77
s = select([t1], t1.c.c2 == t2.c.c1).apply_labels()
78
s.compile(dialect=self.dialect)