~lifeless/storm/with

« back to all changes in this revision

Viewing changes to tests/store/postgres.py

  • Committer: Robert Collins
  • Date: 2011-03-28 00:09:49 UTC
  • Revision ID: robert@canonical.com-20110328000949-67y2qf7a3iqlan12
Add a compiler class to let select expressions be reused by with_.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
import gc
23
23
 
24
24
from storm.database import create_database
25
 
from storm.expr import SQL
 
25
from storm.expr import Alias, With, SQL
26
26
from storm.properties import Enum, Int, List
27
27
from storm.info import get_obj_info
28
28
 
234
234
            ).find(Foo.id, SQL("foo.id in (select id from tmp)"));
235
235
        self.assertTrue(20 in result)
236
236
 
 
237
    def test_with_with_expr(self):
 
238
        expr = self.store.find(Foo.id, Foo.title.like(u'Title 20'))._get_select()
 
239
        result= self.store.with_(With('tmp', expr)).find(Foo.id,
 
240
            SQL("foo.id in (select id from tmp)"))
 
241
        self.assertTrue(20 in result)
 
242
        self.assertEqual(1, result.count())
 
243
 
237
244
 
238
245
class PostgresEmptyResultSetTest(TestHelper, EmptyResultSetTest):
239
246