Let's say I create a table with
db.define_table('booltest', Field('b', 'boolean'))
web2py generates something like
CREATE TABLE booltest (b char(1));
Now we will insert a new record
db.booltest.insert(b=True);
The error message is
"Wert zu lang für Typ character(1)"
which means
"Value too long for character(1)"
Why? Because the generates SQL-statement is
INSERT INTO booltest(b) VALUES ('True') RETURNING id;
But if I would create a table with
CREATE TABLE booltest (b boolean);
the following SQL-statements work.
Try it with the command line interface of postgres.
INSERT INTO bootest2 (b) VALUES('true');
INSERT INTO bootest2 (b) VALUES(TRUE);
INSERT INTO bootest2 (b) VALUES(true);
INSERT INTO bootest2 (b) VALUES(True);
INSERT INTO bootest2 (b) VALUES('T');
INSERT INTO bootest2 (b) VALUES('on');
Therefore I think the following lines should be changed in gluon/dal.py,
after line 2760 (class PostgreSQLAdapter(BaseAdapter);
TRUE = 'True' ==> TRUE = 'T'
FALSE = 'False' ==> FALSE = 'F'
or, better:
types = {'boolean': 'CHAR(1)', ==> types = {'boolean': 'BOOLEAN',
Right? Or did I made a mistake?
I cann't image that I am the first one with this problem...
Regards, Martin
--
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.