return "%s(%s)" % (self.__class__.__name__, id(self))
def oid_column_name(self):
- # NOTE: setting up mappers fails unless the proxy engine returns
- # something for oid column name, and the call happens too early
- # to proxy, so effecticely no oids are allowed when using
- # proxy engine
+ # oid_column should not be requested before the engine is connected.
+ # it should ideally only be called at query compilation time.
e= self.get_engine()
if e is None:
return None
else:
self.onclause = onclause
self.isouter = isouter
- self.oid_column = self.left.oid_column
+
+ oid_column = property(lambda s:s.left.oid_column)
+
def _exportable_columns(self):
return [c for c in self.left.columns] + [c for c in self.right.columns]
def _proxy_column(self, column):
if self.engine.oid_column_name() is not None:
self._oid_column = schema.Column(self.engine.oid_column_name(), sqltypes.Integer, hidden=True)
self._oid_column._set_parent(self)
+ self._orig_columns()[self._oid_column.original] = self._oid_column
else:
self._oid_column = None
return self._oid_column
self._orig_cols= {}
for c in self.columns:
self._orig_cols[c.original] = c
- oid = self.oid_column
- if oid is not None:
- self._orig_cols[oid.original] = oid
return self._orig_cols
columns = property(lambda s:s._columns)
c = property(lambda s:s._columns)
pass
+class ConstructTest(PersistTest):
+ """tests that we can build SQL constructs without engine-specific parameters, particulary
+ oid_column, being needed, as the proxy engine is usually not connected yet."""
+ def test_join(self):
+ engine = ProxyEngine()
+ t = Table('table1', engine,
+ Column('col1', Integer, primary_key=True))
+ t2 = Table('table2', engine,
+ Column('col2', Integer, ForeignKey('table1.col1')))
+ j = join(t, t2)
+
class ProxyEngineTest1(PersistTest):
def setUp(self):