I think you want:
db.define_table('paint',
Field('name', length=30, requires=IS_NOT_EMPTY(),
unique=True),
Field('base_paint', length=3, requires=IS_NOT_EMPTY()),
Field('hex_color', length=6),
format='%(name)s')
db.define_table('tint',
Field('name', length=3, requires=IS_NOT_EMPTY()),
format='%(name)s')
db.define_table('paint_tints',
Field('paint_id', db.paint),
Field('tint_id', db.tint),
Field('units', 'integer'))
volume = IS_IN_SET(['½ Litre', '1 Litre', '10 Litre', '30 Litre'])
letters = IS_EMPTY_OR(IS_IN_SET(["A","B","C","D","E","F"]))
db.define_table('order_que',
Field('customer_code', length=30,requires=IS_NOT_EMPTY()),
Field('paint',db.paint), ### << this was wrong
Field('can_size',requires=volume),
Field('pickup_time'),
Field('que_letter',requires=letters))
# these are all automatic because of format above
#db.order_que.paint.requires = IS_IN_DB(db, 'paint.id', '%(name)s')
#db.paint_tints.paint_id.requires=IS_IN_DB(db, 'paint.id', '%(name)s')
#db.paint_tints.tint_id.requires=IS_IN_DB(db, 'tint.id', '%(name)s')
#db.order_que.customer_code.requires=IS_NOT_EMPTY()
and your select:
plate_que = db(db.order_que.que_letter!=None)
(db.order_que.paint==db.paint.id).select()
On Jan 27, 9:19 am, Jason Brower <[email protected]> wrote:
> I have the paint table and the order_que...
> I wnat to join them to show only tables that have a que_letter. (Not
> none but anything else.)
> BR,
> Jason Brower
>
> On Wed, 2010-01-27 at 06:21 -0800, mdipierro wrote:
> > This is not a valid DAL query
> > plate_que = db((db.order_que.que_letter != None)==db.paint.name).select
> > ()
> > (a!=b)==c?
>
> > can you say in words (or in SQL) what you need to do?
>
> > Massimo
>
> > On Jan 27, 12:49 am, Jason Brower <[email protected]> wrote:
> > > I have a database as follow:
> > > # coding: utf8
> > > from datetime import datetime, date, time
> > > now = datetime.utcnow()
> > > today = date.today()
>
> > > db = SQLDB('sqlite://paint.sqlite')
>
> > > db.define_table('order_que',
> > > Field('customer_code', length=30),
> > > Field('paint'),
> > > Field('can_size', requires=IS_IN_SET(['½ Litre', '1 Litre', '10
> > > Litre', '30 Litre'])),
> > > Field('pickup_time'),
> > > Field('que_letter',
> > > requires=IS_IN_SET([None,"A","B","C","D","E","F"])))
>
> > > db.define_table('paint',
> > > Field('name', length=30, requires=IS_NOT_EMPTY(), unique=True),
> > > Field('base_paint', length=3, requires=IS_NOT_EMPTY()),
> > > Field('hex_color', length=6))
>
> > > db.define_table('tint',
> > > Field('name', length=3, requires=IS_NOT_EMPTY()))
>
> > > db.define_table('paint_tints',
> > > Field('paint_id', db.paint),
> > > Field('tint_id', db.tint),
> > > Field('units', 'integer'))
>
> > > db.order_que.paint.requires = IS_IN_DB(db, 'paint.id', '%(name)s')
> > > db.paint_tints.paint_id.requires=IS_IN_DB(db, 'paint.id', '%(name)s')
> > > db.paint_tints.tint_id.requires=IS_IN_DB(db, 'tint.id', '%(name)s')
> > > db.order_que.customer_code.requires=IS_NOT_EMPTY()
>
> > > And I am trying to do a join like this...
> > > plate_que = db((db.order_que.que_letter != None) ==
> > > db.paint.name).select()
> > > But no matter what I put into order_que.que_letter I don't get any
> > > results. Any ideas?
> > > BR,
> > > Jason
>
>
--
You received this message because you are subscribed to the Google Groups
"web2py-users" 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/web2py?hl=en.