diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-08-14 21:53:32 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-08-14 21:53:32 +0000 |
commit | 087f235c33c1be4e0778231e8344a50dc4005c59 (patch) | |
tree | d47c35d1e520e43c05ec869304870c0b6c87f736 /test/sql/defaults.py | |
parent | e58063aa91d893d76e9f34fbc3ea21818185844d (diff) | |
download | sqlalchemy-087f235c33c1be4e0778231e8344a50dc4005c59.tar.gz |
- merged "fasttypes" branch. this branch changes the signature
of convert_bind_param() and convert_result_value() to callable-returning
bind_processor() and result_processor() methods. if no callable is
returned, no pre/post processing function is called.
- hooks added throughout base/sql/defaults to optimize the calling
of bind param/result processors so that method call overhead is minimized.
special cases added for executemany() scenarios such that unneeded "last row id"
logic doesn't kick in, parameters aren't excessively traversed.
- new performance tests show a combined mass-insert/mass-select test as having 68%
fewer function calls than the same test run against 0.3.
- general performance improvement of result set iteration is around 10-20%.
Diffstat (limited to 'test/sql/defaults.py')
-rw-r--r-- | test/sql/defaults.py | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/test/sql/defaults.py b/test/sql/defaults.py index 0df49ea39..76bd2c41f 100644 --- a/test/sql/defaults.py +++ b/test/sql/defaults.py @@ -9,14 +9,14 @@ import datetime class DefaultTest(PersistTest): def setUpAll(self): - global t, f, f2, ts, currenttime, metadata + global t, f, f2, ts, currenttime, metadata, default_generator db = testbase.db metadata = MetaData(db) - x = {'x':50} + default_generator = {'x':50} def mydefault(): - x['x'] += 1 - return x['x'] + default_generator['x'] += 1 + return default_generator['x'] def myupdate_with_ctx(ctx): return len(ctx.compiled_parameters['col2']) @@ -96,6 +96,7 @@ class DefaultTest(PersistTest): t.drop() def tearDown(self): + default_generator['x'] = 50 t.delete().execute() def testargsignature(self): @@ -125,7 +126,14 @@ class DefaultTest(PersistTest): t.insert().execute() ctexec = currenttime.scalar() - print "Currenttime "+ repr(ctexec) + l = t.select().execute() + today = datetime.date.today() + self.assert_(l.fetchall() == [(51, 'imthedefault', f, ts, ts, ctexec, True, False, 12, today), (52, 'imthedefault', f, ts, ts, ctexec, True, False, 12, today), (53, 'imthedefault', f, ts, ts, ctexec, True, False, 12, today)]) + + def testinsertmany(self): + r = t.insert().execute({}, {}, {}) + + ctexec = currenttime.scalar() l = t.select().execute() today = datetime.date.today() self.assert_(l.fetchall() == [(51, 'imthedefault', f, ts, ts, ctexec, True, False, 12, today), (52, 'imthedefault', f, ts, ts, ctexec, True, False, 12, today), (53, 'imthedefault', f, ts, ts, ctexec, True, False, 12, today)]) @@ -135,6 +143,25 @@ class DefaultTest(PersistTest): l = t.select().execute() self.assert_(l.fetchone()['col3'] == 50) + def testupdatemany(self): + t.insert().execute({}, {}, {}) + + t.update(t.c.col1==bindparam('pkval')).execute( + {'pkval':51,'col7':None, 'col8':None, 'boolcol1':False}, + ) + + + t.update(t.c.col1==bindparam('pkval')).execute( + {'pkval':51,}, + {'pkval':52,}, + {'pkval':53,}, + ) + + l = t.select().execute() + ctexec = currenttime.scalar() + today = datetime.date.today() + self.assert_(l.fetchall() == [(51, 'im the update', f2, ts, ts, ctexec, False, False, 13, today), (52, 'im the update', f2, ts, ts, ctexec, True, False, 13, today), (53, 'im the update', f2, ts, ts, ctexec, True, False, 13, today)]) + def testupdate(self): r = t.insert().execute() @@ -147,7 +174,7 @@ class DefaultTest(PersistTest): self.assert_(l == (pk, 'im the update', f2, None, None, ctexec, True, False, 13, datetime.date.today())) # mysql/other db's return 0 or 1 for count(1) self.assert_(14 <= f2 <= 15) - + def testupdatevalues(self): r = t.insert().execute() pk = r.last_inserted_ids()[0] |