Commits

Mike Bayer committed 34b0f0e

- Adjusted dictlike-polymorphic.py example
to apply the CAST such that it works on
PG, other databases. [ticket:2266]

Comments (0)

Files changed (2)

     dictionary that had tuples as keys would be misinterpreted
     as a sequence. [ticket:2275]
 
+- examples
+  - Adjusted dictlike-polymorphic.py example
+    to apply the CAST such that it works on 
+    PG, other databases.  [ticket:2266]
+    Also in 0.6.9.
+
 0.7.2
 =====
 - orm

examples/vertical/dictlike-polymorphic.py

             self.cls = cls
 
         def _case(self):
-            whens = [(text("'%s'" % p[0]), getattr(self.cls, p[1]))
+            whens = [(text("'%s'" % p[0]), cast(getattr(self.cls, p[1]), String))
                      for p in self.cls.type_map.values()
                      if p[1] is not None]
             return case(whens, self.cls.type, null())
         def __eq__(self, other):
-            return cast(self._case(), String) == cast(other, String)
+            return self._case() == cast(other, String)
         def __ne__(self, other):
-            return cast(self._case(), String) != cast(other, String)
+            return self._case() != cast(other, String)
 
     def __repr__(self):
         return '<%s %r=%r>' % (self.__class__.__name__, self.key, self.value)
 
     mapper(AnimalFact, chars)
 
-    metadata.bind = create_engine('sqlite://', echo=True)
-    metadata.create_all()
-    session = Session()
+    engine = create_engine('sqlite://', echo=True)
+
+    metadata.create_all(engine)
+    session = Session(engine)
 
     stoat = Animal(u'stoat')
     stoat[u'color'] = u'red'
          filter(with_characteristic(u'cuteness', u'very cute')))
     print q.all()
 
-
-    metadata.drop_all()
+    session.close()
+    metadata.drop_all(engine)