Yeah this is really not an easy use case with SQLSoup, you can't use the string
form "" and really if your database has FOREIGN KEY on "unit_purchase_id" you
shouldn't need to be doing this anyway - you'd want to check in your PGAdmin
tool to see if there is in fact an FK constraint on this column.
or just try losing the "" :
primaryjoin=catalog_product.id==catalog_unit.unit_purchase_id
anyway this is why SQLsoup is spun off as it's own project now (it won't be in
SQLAlchemy 0.8), it really needs someone to maintain/document it as it's very
old.
On Mar 24, 2012, at 11:38 PM, temo wrote:
> no, i'm on postgresql, the tables was generated django with syncdb,
>
> i see the example, and change relate() to this:
> self.db.catalog_unit.relate('catalog_product', self.db.catalog_product,
> primaryjoin="catalog_product.id==catalog_unit.unit_purchase_id",
> cascade='all, delete-orphan')
>
> shows this error:
> sqlalchemy.exc.ArgumentError: Column-based expression object expected for
> argument 'primaryjoin'; got:
> 'catalog_product.id==catalog_unit.unit_purchase_id', type <type 'str'>
>
> so, i have to create the tables with Base, like this??:
>
> class Unit(Base):
> __tablename__ = 'catalog_unit'
> id = Column(Integer, primary_key=True)
> name = Column(String)
>
> ....
>
> El viernes 23 de marzo de 2012 22:53:14 UTC-6, Michael Bayer escribió:
> you'd need to specify join conditions as they occur in an example like this
> one:
>
> http://docs.sqlalchemy.org/en/latest/orm/relationships.html#setting-the-primaryjoin-and-secondaryjoin
>
> relate() should accept the same arguments as relationship().
>
> the source of the issue is probably that you're on MySQL using MyISAM tables,
> which do not store any information about FOREIGN KEY constraints and thus
> SQLAlchemy doesn't know they exist when SQLSoup reflects the structure of the
> tables from the database.
>
>
>
>
> On Mar 24, 2012, at 12:47 AM, temo wrote:
>
>> Hi
>>
>> Im mapping a database with sqlsoup and when use db.relate shows this error:
>>
>> sqlalchemy.exc.ArgumentError: Could not determine join condition between
>> parent/child tables on relationship MappedCatalog_unit.catalog_product.
>> Specify a 'primaryjoin' expression. If 'secondary' is present,
>> 'secondaryjoin' is needed as well.
>>
>>
>> this a sample of how looks the relationship in data base
>>
>> catalog_unit:
>> name = char()
>>
>> catalog_product:
>> unit_purchase = ForeignKey(catalog_unit)
>> unit_sale = ForeignKey(catalog_unit)
>>
>> anyone knows how fix it?
>>
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "sqlalchemy" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/sqlalchemy/-/7hRFVPz7MssJ.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> sqlalchemy+unsubscribe@googlegroups.com.
>> 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 view this discussion on the web visit
> https://groups.google.com/d/msg/sqlalchemy/-/-Wp6NEFIpA8J.
> 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.