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:

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?


Petr Jakes

    Oleg Broytmann            http://phd.pp.ru/            phd@phd.pp.ru
          Programmers don't die, they just GOSUB without RETURN.