In many of the adapters, web2py converts booleans to and from strings with
values "T" and "F". So, depending on the adapter, if you are writing SQL
manually, you may need to use those values instead of True and False.
Anthony
On Saturday, March 28, 2015 at 12:14:44 PM UTC-4, Ruud Schroen wrote:
>
> Hi,
>
> I have the following model:
>
> #Abstract category model, has references from multiple translations
> db.define_table('pitch_category') #No fields except for ID
>
> #The category translations
> db.define_table('pitch_category_translation',
> Field('pitch_category', db.pitch_category,
> requires=IS_IN_DB(db,db.pitch_category.id,lambda r:
> get_default_translation(r.id)), label=T('Category')),
> Field('lang', 'string', requires=IS_IN_SET(settings.languages),
> label=T('Language')),
> Field('val', 'string', label=T('The translation')),
> Field('is_default', 'boolean', label=T('This is the default translation.
> NOTE: there should be only one per category!'))
> )
>
>
> When i try to check if is_default is True, i get the following error:
>
> <class 'gluon.contrib.pg8000.ProgrammingError'>(('ERROR', '42804',
> 'argument of IS TRUE must be type boolean, not type character'))
>
> This is my SQL statement:
>
> sql = """
> SELECT
> p.ID,
> tr.val,
> def.val
> FROM pitch_category p
> LEFT OUTER JOIN pitch_category_translation tr
> ON p.ID = tr.pitch_category AND tr.lang = '%s'
> LEFT OUTER JOIN pitch_category_translation def
> ON p.ID = def.pitch_category AND def.is_default IS TRUE;
> """ % language
>
>
> Everything works, except for the boolean check...
>
>
--
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.