Ok, thank you! :) 2012/2/8 Michael Bayer <[email protected]>
> OK, a misunderstanding, the proof of concept is working as of a specific > version (rf41aa3ad1da9) - if you've just checked out the branch then you're > seeing a refactoring of code which is in flux, and that stack trace is > specifically failing on new code that isn't actually doing anything other > than being compared against what the usual relationship() mechanics produce > given a particular input. It isn't yet implemented for the > "local_remote_side" parameter in particular. > > The entire system is not nearly ready for testing in any case, just wanted > to report that a strategy has been devised that solves the issue - thanks ! > > > > On Feb 8, 2012, at 5:31 AM, Pau Tallada wrote: > > Uhm, the test I attached on previous mail fails using this branch: > > $ python test_relationships.py > Traceback (most recent call last): > File "test_relationships (1).py", line 53, in <module> > c1 = Company() > File "<string>", line 2, in __init__ > File > "/home/tallada/Projectes/PIC/multivac/trunk/lib/sqlalchemy_1401.zip/sqlalchemy/orm/instrumentation.py", > line 309, in _new_state_if_none > File > "/home/tallada/Projectes/PIC/multivac/trunk/lib/sqlalchemy_1401.zip/sqlalchemy/util/langhelpers.py", > line 485, in __get__ > File > "/home/tallada/Projectes/PIC/multivac/trunk/lib/sqlalchemy_1401.zip/sqlalchemy/orm/instrumentation.py", > line 157, in _state_constructor > File > "/home/tallada/Projectes/PIC/multivac/trunk/lib/sqlalchemy_1401.zip/sqlalchemy/event.py", > line 274, in __call__ > File > "/home/tallada/Projectes/PIC/multivac/trunk/lib/sqlalchemy_1401.zip/sqlalchemy/orm/mapper.py", > line 2325, in _event_on_first_init > File > "/home/tallada/Projectes/PIC/multivac/trunk/lib/sqlalchemy_1401.zip/sqlalchemy/orm/mapper.py", > line 2250, in configure_mappers > File > "/home/tallada/Projectes/PIC/multivac/trunk/lib/sqlalchemy_1401.zip/sqlalchemy/orm/mapper.py", > line 1166, in _post_configure_properties > File > "/home/tallada/Projectes/PIC/multivac/trunk/lib/sqlalchemy_1401.zip/sqlalchemy/orm/interfaces.py", > line 128, in init > File > "/home/tallada/Projectes/PIC/multivac/trunk/lib/sqlalchemy_1401.zip/sqlalchemy/orm/properties.py", > line 917, in do_init > File > "/home/tallada/Projectes/PIC/multivac/trunk/lib/sqlalchemy_1401.zip/sqlalchemy/orm/properties.py", > line 945, in _create_new_thing > File > "/home/tallada/Projectes/PIC/multivac/trunk/lib/sqlalchemy_1401.zip/sqlalchemy/orm/relationships.py", > line 58, in __init__ > File > "/home/tallada/Projectes/PIC/multivac/trunk/lib/sqlalchemy_1401.zip/sqlalchemy/orm/relationships.py", > line 246, in _parse_joins > File > "/home/tallada/Projectes/PIC/multivac/trunk/lib/sqlalchemy_1401.zip/sqlalchemy/sql/visitors.py", > line 234, in cloned_traverse > File > "/home/tallada/Projectes/PIC/multivac/trunk/lib/sqlalchemy_1401.zip/sqlalchemy/sql/visitors.py", > line 227, in clone > File > "/home/tallada/Projectes/PIC/multivac/trunk/lib/sqlalchemy_1401.zip/sqlalchemy/sql/expression.py", > line 2998, in _copy_internals > File > "/home/tallada/Projectes/PIC/multivac/trunk/lib/sqlalchemy_1401.zip/sqlalchemy/sql/visitors.py", > line 230, in clone > File > "/home/tallada/Projectes/PIC/multivac/trunk/lib/sqlalchemy_1401.zip/sqlalchemy/orm/relationships.py", > line 241, in visit_binary > File > "/home/tallada/Projectes/PIC/multivac/trunk/lib/sqlalchemy_1401.zip/sqlalchemy/orm/relationships.py", > line 165, in _run_w_switch > File > "/home/tallada/Projectes/PIC/multivac/trunk/lib/sqlalchemy_1401.zip/sqlalchemy/orm/relationships.py", > line 222, in go > NotImplementedError > > > 2012/2/8 Pau Tallada <[email protected]> > >> Thank you very much! >> >> I'll test it ASAP :) >> >> >> 2012/2/8 Michael Bayer <[email protected]> >> >>> I have good news on this front, in that I've nailed down how this will >>> work, including a patch that gets this basic thing working as a proof of >>> concept. However, the issue of being able to distinguish "remote" and >>> "foreign" in a binary expression where a column points to itself can >>> benefit from moving completely to the newer concept I'm working on, which >>> is different enough that I think it should be for the next major SQLAlchemy >>> release (currently it's called 0.8). I'll keep the ticket updated with >>> progress reports. >>> >>> >>> On Feb 1, 2012, at 10:49 AM, Michael Bayer wrote: >>> >>> This is essentially ticket #1401 and I've attached this there as well as >>> moved up the priority, however this issue is extremely complicated and >>> would require some serious rethinking of the relationship()'s inner >>> workings. It would take several days to come up with a general solution >>> so I can't give you a fix for this right now. >>> >>> http://www.sqlalchemy.org/trac/ticket/1401 >>> >>> >>> >>> >>> On Feb 1, 2012, at 5:40 AM, Pau Tallada wrote: >>> >>> Hi! >>> >>> I have a table with a self-reference of two columns that represents a >>> tree structure. >>> I was trying to build an outerjoin to select all the nodes have children >>> but NO grandchildren, but the SQL constructed was incorrect, as it was not >>> aliasing properly one of the columns. >>> >>> note_t Table('node_t', metadata, >>> Column('id', Integer, primary_key=True), >>> Column('project_id', Integer), >>> Column('parent_id', Integer), >>> sa.ForeignKeyConstraint( >>> ['project_id', 'parent_id'], >>> ['node_t.project_id', 'node_t.id])) >>> >>> mapper(Node, node_t, properties= { >>> 'children' : relationship(Node, >>> remote_side=[note_t.c.id, node_t.c.project_id] >>> ) >>> }) >>> >>> *print str(session.query(Node).outerjoin(Node, Node.children, >>> aliased=True)))* >>> >>> Generated (simplified): >>> SELECT node.id, node.project_id, node.parent_id >>> FROM node >>> LEFT OUTER JOIN node AS parent ON node.parent_id = parent.id >>> AND node.project_id = *node*.project_id >>> >>> Expected: >>> SELECT node.id, node.project_id, node.parent_id >>> FROM node >>> LEFT OUTER JOIN node AS parent ON node.parent_id = parent.id >>> AND node.project_id = *parent*.project_id >>> * >>> * >>> Making the join condition explicit generates the correct SQL >>> *Parent = aliased(Node)* >>> *print str(session.query(**Node**).outerjoin(**Parent**, >>> (Node.parent_id == Parent.id) & (Node.project_id == Parent.project_id))) >>> * >>> * >>> * >>> I have attached a small test file (test.py) that shows this behaviour >>> and is based on one of your tests suites (test_relationships). >>> >>> Thanks in advance! >>> >>> Pau. >>> -- >>> ---------------------------------- >>> Pau Tallada Crespí >>> Dep. d'Astrofísica i Cosmologia >>> Port d'Informació Científica (PIC) >>> Tel: +34 93 586 8233 >>> ---------------------------------- >>> >>> >>> >>> -- >>> 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. >>> <test.py> >>> >>> >>> >>> -- >>> 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. >>> >>> >>> >>> -- >>> 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. >>> >> >> >> >> -- >> ---------------------------------- >> Pau Tallada Crespí >> Dep. d'Astrofísica i Cosmologia >> Port d'Informació Científica (PIC) >> Tel: +34 93 586 8233 >> ---------------------------------- >> >> >> > > > -- > ---------------------------------- > Pau Tallada Crespí > Dep. d'Astrofísica i Cosmologia > Port d'Informació Científica (PIC) > Tel: +34 93 586 8233 > ---------------------------------- > > > > -- > 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. > > > -- > 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. > -- ---------------------------------- Pau Tallada Crespí Dep. d'Astrofísica i Cosmologia Port d'Informació Científica (PIC) Tel: +34 93 586 8233 ---------------------------------- -- 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.
