Thanks for the help on this Anthony. I ended up using the lambda function and the orderby to get what I needed. Would be great to see the left join supported here.
On Fri, Apr 12, 2013 at 9:07 PM, Jim Steil <[email protected]> wrote: > That perfect. I'll get it going next week. Thanks for the help with this. > > Jim > On Apr 12, 2013 8:57 PM, "Anthony" <[email protected]> wrote: > >> No, you can't do the ._select(). However, IS_IN_DB takes orderby, >> groupby, and distinct arguments (though not "left", which presumably could >> be added) and uses them in the .select() that it does. You don't expect all >> this stuff to be documented, do you? We have to have something to talk >> about on Google Groups. ;-) >> >> Anthony >> >> On Friday, April 12, 2013 9:41:58 PM UTC-4, Jim S wrote: >>> >>> In the _select() ? >>> On Apr 12, 2013 8:41 PM, "Anthony" <[email protected]> wrote: >>> >>>> You can specify an orderby for the query. >>>> >>>> Anthony >>>> >>>> On Friday, April 12, 2013 8:20:38 PM UTC-4, Jim S wrote: >>>>> >>>>> So, that should allow me to sort though shouldn't it? >>>>> On Apr 12, 2013 4:38 PM, "Anthony" <[email protected]> wrote: >>>>> >>>>>> Well, a change was just made in trunk to allow >>>>>> '%(tablename.fieldname)s' notation, but it looks like the query retains >>>>>> only the fields in the main table (db.productSite in this case) anyway, >>>>>> so >>>>>> I guess that won't help. So instead, maybe: >>>>>> >>>>>> lambda r: db(db.product.productId == r.productId).select().first().** >>>>>> **productName >>>>>> >>>>>> Anthony >>>>>> >>>>>> On Friday, April 12, 2013 1:56:34 PM UTC-4, Jim S wrote: >>>>>>> >>>>>>> requires = IS_IN_DB(db((~db.productSite.**p**** >>>>>>> roductSiteId.belongs(**currentIt****ems)) & >>>>>>> (db.productSite.**availableAddo****n==True) >>>>>>> & >>>>>>> >>>>>>> (db.productSite.siteId==**worko****rder.siteId) >>>>>>> & >>>>>>> (db.product.productId==db.**pro**** >>>>>>> ductSite.productId)), >>>>>>> db.productSite.productSiteId, >>>>>>> lambda r: r.product.productName, zero='..') >>>>>>> >>>>>>> ...gives me... >>>>>>> >>>>>>> Traceback (most recent call last): >>>>>>> File "C:\dev\web2py\gluon\**restricte****d.py", line 212, in >>>>>>> restricted >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> exec ccode in environment >>>>>>> File >>>>>>> "C:/dev/web2py/applications/**in****focenter/controllers/**applicati****ons.py" >>>>>>> >>>>>>> <http://10.10.2.34:8000/admin/default/edit/infocenter/controllers/applications.py>, >>>>>>> line 4291, in <module> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> File "C:\dev\web2py\gluon\globals.**p****y", line 194, in <lambda> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> self._caller = lambda f: f() >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> File "C:\dev\web2py\gluon\tools.py"******, line 2976, in f >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> return action(*a, **b) >>>>>>> File >>>>>>> "C:/dev/web2py/applications/**in****focenter/controllers/**applicati****ons.py" >>>>>>> >>>>>>> <http://10.10.2.34:8000/admin/default/edit/infocenter/controllers/applications.py>, >>>>>>> line 864, in workorderBom >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> _formname='addonForm') >>>>>>> File "C:\dev\web2py\gluon\sqlhtml.**p****y", line 1599, in factory >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> **attributes) >>>>>>> File "C:\dev\web2py\gluon\sqlhtml.**p****y", line 1113, in __init__ >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> inp = self.widgets.options.widget(fi******eld, default) >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> File "C:\dev\web2py\gluon\sqlhtml.**p****y", line 252, in widget >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> options = requires[0].options() >>>>>>> File "C:\dev\web2py\gluon\**validator****s.py", line 546, in options >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> self.build_set() >>>>>>> File "C:\dev\web2py\gluon\**validator****s.py", line 543, in build_set >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> self.labels = [self.label(r) for r in records] >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> File >>>>>>> "C:/dev/web2py/applications/**in****focenter/controllers/**applicati****ons.py" >>>>>>> >>>>>>> <http://10.10.2.34:8000/admin/default/edit/infocenter/controllers/applications.py>, >>>>>>> line 853, in <lambda> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> lambda r: r.product.productName, zero='..') >>>>>>> >>>>>>> >>>>>>> >>>>>>> AttributeError: 'Row' object has no attribute 'product' >>>>>>> >>>>>>> >>>>>>> >>>>>>> On Fri, Apr 12, 2013 at 12:10 PM, Jim Steil <[email protected]>wrote: >>>>>>> >>>>>>>> Shoot, should have thought of that. >>>>>>>> >>>>>>>> Will try when I get back to the office. >>>>>>>> >>>>>>>> Jim >>>>>>>> On Apr 12, 2013 12:04 PM, "Anthony" <[email protected]> wrote: >>>>>>>> >>>>>>>>> It probably should work, but for some reason, the code converts >>>>>>>>> the Row to a dict before doing the string formatting, and that breaks >>>>>>>>> for >>>>>>>>> Rows involving joins. For now, you can use a lambda instead: >>>>>>>>> >>>>>>>>> lambda r: r.product.productName >>>>>>>>> >>>>>>>>> Anthony >>>>>>>>> >>>>>>>>> On Friday, April 12, 2013 12:38:09 PM UTC-4, Jim S wrote: >>>>>>>>>> >>>>>>>>>> Tried that already but got the same error. >>>>>>>>>> >>>>>>>>>> Jim >>>>>>>>>> On Apr 12, 2013 11:32 AM, "Anthony" <[email protected]> wrote: >>>>>>>>>> >>>>>>>>>>> Since you are joining tables, you might need to use the >>>>>>>>>>> "tablename.fieldname" format to refer to the field in question. Does >>>>>>>>>>> '%(product.productName)s' work (assuming "productName" is in the >>>>>>>>>>> db.product >>>>>>>>>>> table)? >>>>>>>>>>> >>>>>>>>>>> Anthony >>>>>>>>>>> >>>>>>>>>>> On Friday, April 12, 2013 11:59:59 AM UTC-4, Jim S wrote: >>>>>>>>>>>> >>>>>>>>>>>> requires = IS_IN_DB(db((~db.productSite.**p******** >>>>>>>>>>>> roductSiteId.belongs(**currentIt********ems)) & >>>>>>>>>>>> (db.productSite.**availableAddo***** >>>>>>>>>>>> ***n==True) & >>>>>>>>>>>> (db.productSite.siteId==**worko***** >>>>>>>>>>>> ***rder.siteId) & >>>>>>>>>>>> (db.product.productId==db.**pro***** >>>>>>>>>>>> ***ductSite.productId)), >>>>>>>>>>>> db.productSite.productSiteId, >>>>>>>>>>>> '%(productName)s', zero='..') >>>>>>>>>>>> >>>>>>>>>>>> I get a trace back with this. If I pull out the >>>>>>>>>>>> '%(productName)s' it works. But, I want to specify the field >>>>>>>>>>>> name to >>>>>>>>>>>> display being a field in the table linked by the 4 'anded' query. >>>>>>>>>>>> >>>>>>>>>>>> Help? >>>>>>>>>>>> >>>>>>>>>>>> -Jim >>>>>>>>>>>> >>>>>>>>>>> -- >>>>>>>>>>> >>>>>>>>>>> --- >>>>>>>>>>> You received this message because you are subscribed to a topic >>>>>>>>>>> in the Google Groups "web2py-users" group. >>>>>>>>>>> To unsubscribe from this topic, visit >>>>>>>>>>> https://groups.google.com/d/**to******pic/web2py/vb0268kC_mc/** >>>>>>>>>>> unsubsc******ribe?hl=en<https://groups.google.com/d/topic/web2py/vb0268kC_mc/unsubscribe?hl=en> >>>>>>>>>>> . >>>>>>>>>>> To unsubscribe from this group and all its topics, send an email >>>>>>>>>>> to web2py+un...@**googlegroups.com. >>>>>>>>>>> For more options, visit https://groups.google.com/**grou****** >>>>>>>>>>> ps/opt_out <https://groups.google.com/groups/opt_out>. >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>> -- >>>>>>>>> >>>>>>>>> --- >>>>>>>>> You received this message because you are subscribed to a topic in >>>>>>>>> the Google Groups "web2py-users" group. >>>>>>>>> To unsubscribe from this topic, visit https://groups.google.com/d/ >>>>>>>>> **to****pic/web2py/vb0268kC_mc/**unsubsc****ribe?hl=en<https://groups.google.com/d/topic/web2py/vb0268kC_mc/unsubscribe?hl=en> >>>>>>>>> . >>>>>>>>> To unsubscribe from this group and all its topics, send an email >>>>>>>>> to web2py+un...@**googlegroups.com. >>>>>>>>> For more options, visit https://groups.google.com/**grou**** >>>>>>>>> ps/opt_out <https://groups.google.com/groups/opt_out>. >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>> >>>>>>> -- >>>>>> >>>>>> --- >>>>>> You received this message because you are subscribed to a topic in >>>>>> the Google Groups "web2py-users" group. >>>>>> To unsubscribe from this topic, visit https://groups.google.com/d/** >>>>>> to**pic/web2py/vb0268kC_mc/**unsubsc**ribe?hl=en<https://groups.google.com/d/topic/web2py/vb0268kC_mc/unsubscribe?hl=en> >>>>>> . >>>>>> To unsubscribe from this group and all its topics, send an email to >>>>>> web2py+un...@**googlegroups.com. >>>>>> For more options, visit >>>>>> https://groups.google.com/**grou**ps/opt_out<https://groups.google.com/groups/opt_out> >>>>>> . >>>>>> >>>>>> >>>>>> >>>>> -- >>>> >>>> --- >>>> You received this message because you are subscribed to a topic in the >>>> Google Groups "web2py-users" group. >>>> To unsubscribe from this topic, visit https://groups.google.com/d/** >>>> topic/web2py/vb0268kC_mc/**unsubscribe?hl=en<https://groups.google.com/d/topic/web2py/vb0268kC_mc/unsubscribe?hl=en> >>>> . >>>> To unsubscribe from this group and all its topics, send an email to >>>> web2py+un...@**googlegroups.com. >>>> For more options, visit >>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out> >>>> . >>>> >>>> >>>> >>> -- >> >> --- >> You received this message because you are subscribed to a topic in the >> Google Groups "web2py-users" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/web2py/vb0268kC_mc/unsubscribe?hl=en. >> To unsubscribe from this group and all its topics, send an email to >> [email protected]. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

