On Nov 28, 2007 11:40 PM, Oleg Broytmann wrote:

> On Wed, Nov 28, 2007 at 11:34:49PM +0100, Petr Jake?? wrote:
> > But there is not MultipleJoin or RelatedJoin in the given example ....
>
>   But there are no descriptions for Customer and Contact tables/classes,
> and still we dare to call Customer.select() (-;
>   What do you think customer.contacts is?


I see, I am getting closer. What I am really do is I am trying to query
existing tables. The code I allready have looks:

class Customer(SQLObject):
    class sqlmeta:
        fromDatabase = True
        idName = "CUST_NO"
    sales = MultipleJoin('Sales')

class Sales(SQLObject):
    class sqlmeta:
        fromDatabase = True
        idName = "PO_NUMBER"
        idType= str
        custNo = ForeignKey('Customer')

Customer.sqlmeta.addJoin(MultipleJoin('Sales', joinMethodName='custNo'))

for customer in Customer.select():
    print customer.contactFirst, customer.contactLast
    for contact in customer.sales:
        pass

Select on the master (Customer) table is OK, but than the code tries:
1/QueryAll:  SELECT PO_NUMBER FROM sales WHERE customer_id = (1001)
 1/QueryR  :  SELECT PO_NUMBER FROM sales WHERE customer_id = (1001)

which si a wrong SELECT, because the field customer_id does not exists (the
name is generated by the code, even idName = "CUST_NO" is defined in the
class Customer).

How can I "force" SQLObject to use CUST_NO field name instead the
customer_id which is "generated" by the code?

Thanks.

Petr Jakes

>
>
> Oleg.
> --
>     Oleg Broytmann            http://phd.pp.ru/            [EMAIL PROTECTED]
>           Programmers don't die, they just GOSUB without RETURN.
>
>
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to