On Nov 8, 2007, at 2:01 AM, [EMAIL PROTECTED] wrote:
> i dont really understand why u need the ACP being so different to
> plain
> visitor; i mean cant they share some skeleton part of traversing,
> while
> putting all the choices (visit* vs convert; onentry/onexit; stop/dont)
> in their own parts.
> After all, visitor pattern is twofold, a) Guide + b) Visitor; the
> Guide
> doing traversing, the Visitor noting things; choice where to go
> might be
> in visitor and/or in guide. some times (one extreme) the visitor is
> just
> one dumb functor; other cases (other extreme end) the visitor is very
> sofisticated and even does guiding/traversing.
> Here it looks more like second case, u have most of both sides put in
> the Visitor, and only small part (specific visit_* / copy_internals)
> left to the actual nodes.
> And to me, the skeleton is still same between ACP and ClauseVisitor.
you cant use plain visitor beacuse you are copying the whole structure
in place at the same time, and a method is deciding arbitrarily to not
copy certain elements, and instead returns an element that was set
from the outside; that element cannot be mutated since its not from
the original structure, therefore it cannot be traversed.
as it turns out, this visitor still has lots of problems which will
continue to prevent more sophisticated copy-and-replace
operations...some of the ways that a Select() just works from the
ground up just get in the way here.
if you are curious why there was a rewrite, heres the test which
needed to pass:
metadata = MetaData()
a = Table('a', metadata,
Column('id', Integer, primary_key=True))
b = Table('b', metadata,
Column('id', Integer, primary_key=True),
Column('aid', Integer, ForeignKey('a.id')),
)
c = Table('c', metadata,
Column('id', Integer, primary_key=True),
Column('bid', Integer, ForeignKey('b.id')),
)
d = Table('d', metadata,
Column('id', Integer, primary_key=True),
Column('aid', Integer, ForeignKey('a.id')),
)
j1 = a.outerjoin(b)
j2 = select([j1], use_labels=True)
j3 = c.join(j2, j2.c.b_id==c.c.bid)
j4 = j3.outerjoin(d)
self.assert_compile(j4, "c JOIN (SELECT a.id AS a_id, b.id
AS b_id, b.aid AS b_aid FROM a LEFT OUTER JOIN b ON a.id = b.aid) "
"ON b_id = c.bid"
" LEFT OUTER JOIN d ON a_id = d.aid")
j5 = j3.alias('foo')
j6 = sql_util.ClauseAdapter(j5).copy_and_process([j4])[0]
# this statement takes c join(a join b), wraps it inside an
aliased "select * from c join(a join b) AS foo".
# the outermost right side "left outer join d" stays the
same, except "d" joins against foo.a_id instead
# of plain "a_id"
self.assert_compile(j6, "(SELECT c.id AS c_id, c.bid AS
c_bid, a_id AS a_id, b_id AS b_id, b_aid AS b_aid FROM "
"c JOIN (SELECT a.id AS a_id, b.id AS
b_id, b.aid AS b_aid FROM a LEFT OUTER JOIN b ON a.id = b.aid) "
"ON b_id = c.bid) AS foo"
" LEFT OUTER JOIN d ON foo.a_id =
d.aid")
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---