- engines
- Connections gain a .properties collection, with contents scoped to the
lifetime of the underlying DBAPI connection
+ - ColumnCollection (i.e. the 'c' attribute on tables) follows dictionary
+ semantics for "__contains__" [ticket:606]
- extensions
- proxyengine is temporarily removed, pending an actually working
replacement.
# load "polymorphic" versions of the columns present in "remote_side" - this is
# important for lazy-clause generation which goes off the polymorphic target selectable
for c in list(self.remote_side):
- if self.secondary and c in self.secondary.columns:
+ if self.secondary and self.secondary.columns.contains_column(c):
continue
for equiv in [c] + (c in target_equivalents and list(target_equivalents[c]) or []):
corr = self.mapper.select_table.corresponding_column(equiv, raiseerr=False)
self.columns = sql.ColumnCollection()
def __contains__(self, x):
- return x in self.columns
+ return self.columns.contains_column(x)
def keys(self):
return self.columns.keys()
l.append(c==local)
return and_(*l)
- def __contains__(self, col):
- return self.contains_column(col)
+ def __contains__(self, other):
+ if not isinstance(other, basestring):
+ raise exceptions.ArgumentError("__contains__ requires a string argument")
+ return self.has_key(other)
def contains_column(self, col):
# have to use a Set here, because it will compare the identity
the exported columns of this ``FromClause``.
"""
- if column in self.c:
+ if self.c.contains_column(column):
return column
if require_embedded and column not in util.Set(self._get_all_embedded_columns()):
import testbase
-from sqlalchemy import util
+from sqlalchemy import util, column, sql, exceptions
from testlib import *
self.assert_(o.keys() == ['a', 'b', 'c', 'd', 'e', 'f'])
self.assert_(o.values() == [1, 2, 3, 4, 5, 6])
+class ColumnCollectionTest(PersistTest):
+ def test_in(self):
+ cc = sql.ColumnCollection()
+ cc.add(column('col1'))
+ cc.add(column('col2'))
+ cc.add(column('col3'))
+ assert 'col1' in cc
+ assert 'col2' in cc
+
+ try:
+ cc['col1'] in cc
+ assert False
+ except exceptions.ArgumentError, e:
+ assert str(e) == "__contains__ requires a string argument"
+
+ def test_compare(self):
+ cc1 = sql.ColumnCollection()
+ cc2 = sql.ColumnCollection()
+ cc3 = sql.ColumnCollection()
+ c1 = column('col1')
+ c2 = c1.label('col2')
+ c3 = column('col3')
+ cc1.add(c1)
+ cc2.add(c2)
+ cc3.add(c3)
+ assert (cc1==cc2).compare(c1 == c2)
+ assert not (cc1==cc3).compare(c2 == c3)
+
+
if __name__ == "__main__":
testbase.main()