Michael Bayer ha scritto:
> On Jun 11, 2007, at 11:12 AM, Glauco wrote:
>
>   
>> This cause a lot of inspiegable problem to property that are perfecly
>> functional in the primary
>> sqlalchemy.exceptions.ArgumentError: Can't determine relation  
>> direction
>> for relationship 'Blabla.comune_nascita (Comune)' - foreign key  
>> columns
>> are present in neither the parent nor the child's mapped tables
>>
>>     
>
> you need to explicitly specify conditions like primaryjoin,  
> foreign_keys, etc.
>
> http://www.sqlalchemy.org/docs/ 
> adv_datamapping.html#advdatamapping_properties_customjoin
>
>   

For this reason i've inserted explicit primaryjoin condition, and these 
condition work perfectly in the primary mapper.
But in the secondary wont work...


class Anagrafica:
  bla bla

# my primary mapper
assign_mapper(context,
              Anagrafica,
              tbl['anagrafica'],
              column_prefix = 'anagrafica_',
              extension = SelectResultsExt(),
              properties = {
                'comune'         : relation( Comune,
                   primaryjoin = tbl['anagrafica'].c.id_comune == 
tbl['comune'].c.id ),
                'nazione'        : relation( Nazione,
                   primaryjoin = tbl['anagrafica'].c.cod_nazionalita == 
tbl['nazione'].c.codice ),?
                'comune_nascita' : relation( Comune,
                   primaryjoin = tbl['anagrafica'].c.id_comune_nascita 
== tbl['comune'].c.id),
                'nazione_nascita' : relation(Nazione,
                   primaryjoin = tbl['anagrafica'].c.cod_nazione_nascita 
== tbl['nazione'].c.codice ),
                'professione'    : relation( Professione ),
                'titolo_studio'  : relation( TitoloStudio ),
                })


# my secondary mapper
class Person( Anagrafica ):
    pass

assign_mapper(context,
              Person,
              select([tbl['anagrafica']], tbl['anagrafica'].c.tipo == 
'P').alias('person'),
              column_prefix = 'anagrafica_',
              extension = SelectResultsExt(),
              non_primary = True,
              properties = {
                'comune'         : relation( Comune,
                   primaryjoin = tbl['anagrafica'].c.id_comune == 
tbl['comune'].c.id ),
                'nazione'        : relation( Nazione,
                   primaryjoin = tbl['anagrafica'].c.cod_nazionalita == 
tbl['nazione'].c.codice ),?
                'comune_nascita' : relation( Comune,
                   primaryjoin = tbl['anagrafica'].c.id_comune_nascita 
== tbl['comune'].c.id),
                'nazione_nascita' : relation(Nazione,
                   primaryjoin = tbl['anagrafica'].c.cod_nazione_nascita 
== tbl['nazione'].c.codice ),
                'professione'    : relation( Professione ),
                'titolo_studio'  : relation( TitoloStudio ),
                })


In [8]: Anagrafica.search()
Out[8]: <sqlalchemy.ext.selectresults.SelectResults object at 0xb6dfa92c>


In [9]: Person.search()
ArgumentError: Can't determine relation direction for relationship 
'Person.comune_nascita (Comune)' - foreign key columns are present in 
neither the parent nor the child's mapped tables




Some ideas?

Thank you
Glauco

-- 
+------------------------------------------------------------+
                                  Glauco Uri - Programmatore
                                    glauco(at)allevatori.com 
                               
  Sfera Carta Software(r)      [EMAIL PROTECTED]
  Via Bazzanese,69  Casalecchio di Reno(BO) - Tel. 051591054 
+------------------------------------------------------------+



--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to