> > heh, i don't have a vague idea what it should be.
>
> because you dont want to learn SQL.   but if youre really trying to
> write a one-person system on the scale of complexity of SAP, which
> usually have...i dunno, several hundred developers for many years ?
> i think youre gonna have to.
learning SQL and learning how to use SQL are diff.things. Many ppl 
know python but few actualy _know_ it. i don't want to _know_ sql - 
e.g. the way u do.

> > i see at web that what i'm describing is called self-join.
> > So basicaly, self-referential/self-joining queries cannot be done
> > in SA?
>
> the only query that SA explicitly says "no" to is a
> self-referential eager load.   the rest, it will try and see how
> far it gets.   all ORMs require you to hand-code queries for
> criterions that are too complicated.

i think i managed to construct a proper thing, changing 
PropertyLoader.get_join(), and made my own join_via():

PropertyLoader.get_join():
.....
    #add these before the secondaryjoin is and-ed:
            if parent is self.mapper:
                self_select_table = self.mapper.select_table.alias()
                primaryjoin.accept_visitor( sql_util.ClauseAdapter(
                    self_select_table, equivalents=parent_equivalents,
                        exclude=self.foreignkey,  #noidea is it exclude or 
include or what
                ))
....

join_via(): tracking/returning also the last used sub_clause/mapper

and then (from the last_sub_clause) somehow reaching the target 
aliased column and use its table as base of the comparison:
...........
     via_names = hierarchname[1:-1]
     last_attr = hierarchname[-1]
     clause, lastmapper, lastsubclause = join_via( via_names, mapper0)
     lastcol = lastmapper.prop[ last_attr]
     lastrefofclause = lastsubclause.right
     if isinstance( lastrefofclause.table, sql.Alias):
        lastcol = lastcol._make_proxy( lastrefofclause.table )
     return clause, lastcol
     ## and now eventualy and_ the clause and lastcol
......... 

The last-referred-aliased-table picking above is flaky, cannot make 
anything better for now - unless interface of get_join() is also 
changed to return that explicitly..

Any idea to incorporate such/similar functionality in SA? Probably 
with more stuff going on around polymorph-unions, secondary-joins  
etc.

> >> On Feb 15, 9:41 am, svilen <[EMAIL PROTECTED]> wrote:
> >>> and, how u make the (3) or (4) work?
> >>> aliasing the table.column in the comparison does not help.. it
> >>> should be aliased somehow inside the join also..
> >>>
> >>> Here a simpler case, without the inheritance.
> >>> 3 and 4 do not work here too - one does exception, other return
> >>> nothing.
> >>>
> >>> maybe express the query in another way? how?
> >>>
> >>> ciao
> >>> svil
> >>>
> >>>> taking a look, i think what you should do is use an alias of
> >>>> the table_Employee in your queries.  since the engineer mapper
> >>>> is using joined table inheritance, the default table_Employee
> >>>> is already going to be involved in the query, so your external
> >>>> join condition needs to be off a distinct alias of it to
> >>>> prevent mixups.
> >>>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to