On Tuesday, April 25, 2017 at 12:18:29 AM UTC-4, Jim Russell wrote:
>
> Hi all.
>
> I'm having an issue with an SQLFORM.gird query. I have a table where one
> of the columns references another table. Here are the table definitions:
>
> db.define_table('osrwhitelistpool',
> Field('id', type='id'),
> Field('pool', type='string', length=255, unique=True),
> Field('wltype', type='reference osrwlpooltype'),
> Field('comments', type='string', length=255),
> Field('ctime', type='datetime', default=request.now))
>
> db.define_table('osrwlpooltype',
> Field('id', type='id'),
> Field('wtype', type='string', length=32, unique=True))
>
> So osrwhitelistpool field wltype references osrwlpooltype field wtype.
>
> When I run a simple query, just requesting the whole table I get an error
> Query
> Not Supported: invalid literal for long() with base 10: 'ALL'
>
> I'm not sure why it thinks that field should be a long.
>
A reference field stores record IDs from the referenced table, so yes, it
should store long integers. There are two problems with your code. First,
you should define the referenced table before the referencing table, not
after. Second, you should add a "format" argument to referenced table
indicating how reference fields should display their values. If you make
those two changes, you will get two things: (1) in forms based on
osrwhitelistpool, you will get a drop-down for the wltype field showing all
the possible values from the osrwlpooltype table (though the list will show
the formatted values based on the "format" argument rather than the actual
record IDs); (2) in the grid, the values of wltype will be displayed based
on the "format" argument of the osrwlpooltype table.
Anthony
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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/d/optout.