After I posted this the thread focused on John's problem and then hung. Any
thoughts
on this:
Paul McNett wrote:
> Ed Leafe wrote:
>> On Apr 22, 2009, at 4:25 PM, Paul McNett wrote:
>>
>>> I think what is happening is that I'm constructing the SQL from clause
>>> as follows:
>>>
>>> 111 self.setFromClause("""prod_cust
>>> 112 left join product_lines
>>> 113 on product_lines.id = prod_cust.prod_id
>>> 114 left join customers
>>> 115 on customers.id = prod_cust.cust_id""")
>>>
>>> The new code in setChildFilter() seems to assume (by using split()
>>> [-1])
>>> that the last word in the from clause is going to be the table alias,
>>> but in my case the last 'word' is 'prod_cust.cust_id'.
>>>
>>> My code above was written prior to dabo having addJoin() and I could
>>> certainly rewrite it, but I really don't want to have to if it can be
>>> avoided (there are many bizobjs written this way).
>> OK, there are several approaches to take. One is to forbid implicit
>> aliases, and require that from clauses be set with a specific alias
>> name. Right now I'm parsing the from clause to get the alias, and non-
>> standard from clauses like the one above will not work. The other is
>> to require that SQL Builder usage follow certain standards, which your
>> setFromClause() clearly violates.
>>
>> Can you think of any other approach? It would have to handle all of
>> the following:
>>
>> self.setFromClause("prod_cust")
>> self.setFromClause("prod_cust pc")
>> self.setFromClause("prod_cust as pc")
>> self.setFromClause("""prod_cust
>> left join product_lines
>> on product_lines.id = prod_cust.prod_id
>> left join customers
>> on customers.id = prod_cust.cust_id""")
>> self.setFromClause("""prod_cust pc
>> left join product_lines
>> on product_lines.id = prod_cust.prod_id
>> left join customers
>> on customers.id = prod_cust.cust_id""")
>> self.setFromClause("""prod_cust as pc
>> left join product_lines
>> on product_lines.id = prod_cust.prod_id
>> left join customers
>> on customers.id = prod_cust.cust_id""")
>
> It would also need to handle the joins not being on separate lines like I
> have them.
>
> Let's keep the implicitness if we can. BTW I don't consider my from clause
> non-standard, because I've always thought of JOIN as a subclause of FROM.
>
> How about something like (untested; looking for comments on the approach
> only):
>
> def getTableAlias(fromClause):
> join_strings = ["left join", "right join", "outer join", "inner join",
> "join"]
> for join_string in join_strings:
> at = fromClause.lower().find(join_string)
> if at >= 0:
> fromClause = fromClause[:at].strip()
> break
> return fromClause.strip()[-1]
Paul
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/[email protected]