Hello,

I need to map *a new* boolean field in a real postgresql bolean field.

In an old post from 2012 I found this:
 

> I understand the problem. You can chance the DB type (and you did) but 
> web2py still tries to put an 'F' or a 'T' in there.
>
> I modified trunk so that this can be achieved:
>
> import copy
> db =DAL()
> db._adapter.types = copy.copy(db._adapter.types)
> db._adapter.types['boolean']='TINYINT(1)'
> db._adapter.TRUE = 1
> db._adapter.FALSE = 0
> db.define_table('test',Field('b', 'boolean'))
> db.test.insert(b=True)
> db.test.insert(b=False)
> rows = db(db.test).select()
> print db.executesql(db(db.test)._select())
>
>
> this should work fine.
>

So I tried (seems to be crude :) :

db._adapter.types = copy.copy(db._adapter.types)
db._adapter.types['boolean2']='BOOLEAN'
db.define_table('test_xx1',Field('b', 'boolean2'))
db.test_xx1.insert(b="1")
db.test_xx1.insert(b="0")


 This seems to work, the field b in the database is boolean and contains 
TRUE und FALSE values.

But if I open the table in appadmin i get:


 Traceback (most recent call last):
 File 
"/vhost1/kd3143/domains/umweltanalyse-portal.de/docs/applications/portal/controllers/appadmin.py"
, line 269, in select
 *fields, limitby=(start, stop))
 File 
"/vhost1/kd3143/domains/umweltanalyse-portal.de/docs/gluon/packages/dal/pydal/objects.py"
, line 2025, in select
 return adapter.select(self.query,fields,attributes)
 File 
"/vhost1/kd3143/domains/umweltanalyse-portal.de/docs/gluon/packages/dal/pydal/adapters/base.py"
, line 1293, in select
 return self._select_aux(sql,fields,attributes)
 File 
"/vhost1/kd3143/domains/umweltanalyse-portal.de/docs/gluon/packages/dal/pydal/adapters/base.py"
, line 1274, in _select_aux
 return processor(rows,fields,self._colnames,cacheable=cacheable)
 File 
"/vhost1/kd3143/domains/umweltanalyse-portal.de/docs/gluon/packages/dal/pydal/adapters/base.py"
, line 1764, in parse
 for row in rows]
 File 
"/vhost1/kd3143/domains/umweltanalyse-portal.de/docs/gluon/packages/dal/pydal/adapters/base.py"
, line 1674, in _parse
 value = self.parse_value(value, ft, blob_decode)
 File 
"/vhost1/kd3143/domains/umweltanalyse-portal.de/docs/gluon/packages/dal/pydal/adapters/base.py"
, line 1524, in parse_value
 return self.parsemap[key](value,field_type)
KeyError: 'boolean2'


What is the correct code to archieve this?


I need the regular web2py boolean field plus a new field type in web2py 
with another name for real boolean. Is this possible?


I use web2py 2.13.4 and PostgreSQL 9.4.5.

Regards,
Mike

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to