This is a reasonable error now.

when you change a field type (but not the name) web2py tries to
convert the data. In this case postgres fails because it does not know
how to convert dates to integers.

You have to do it in multiple steps:

- remove the field from define_table
- run appadmin once (field will be dropped)
- add the field again with same name and different type
- run appadmin once (new field will be created)

web2py will not try to attepmt to post the data in the column and it
will be lost, but no error.



On Nov 18, 1:20 am, Johann Spies <johann.sp...@gmail.com> wrote:
> On 16 November 2010 21:48, Carlos <carlosgali...@gmail.com> wrote:
>
>
>
> > Johann, please send the files when you get this error too.
>
> It happened just now again.  I  have changed the type of a field from 'date'
> to 'integer' (I want None or year) and the following typical error occured:
>
> Traceback
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
> 17.
> 18.
> 19.
>
> Traceback (most recent call last):
>   File "/home/js/web2py/gluon/restricted.py", line 188, in restricted
>     exec ccode in environment
>   File "/home/js/web2py/applications/kb/models/kb5.py"
> <http://localhost:8000/admin/default/edit/kb/models/kb5.py>, line 229,
> in <module>
>     signature)
>   File "/home/js/web2py/gluon/sql.py", line 1378, in define_table
>     t._create(migrate=migrate, fake_migrate=fake_migrate)
>   File "/home/js/web2py/gluon/sql.py", line 1874, in _create
>     fake_migrate=fake_migrate)
>   File "/home/js/web2py/gluon/sql.py", line 1947, in _migrate
>     self._db._execute(sub_query)
>   File "/home/js/web2py/gluon/sql.py", line 1033, in <lambda>
>     self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
> ProgrammingError: column "datum__tmp" is of type integer but
> expression is of type date
> LINE 1: UPDATE outeur_instansie SET datum__tmp=datum;
>                                                ^
> HINT:  You will need to rewrite or cast the expression.
>
>  Error snapshot [image: help] Detailed traceback description
>
> <class 'psycopg2.ProgrammingError'>(column "datum__tmp" is of type integer
> but expression is of type date LINE 1: UPDATE outeur_instansie SET
> datum__tmp=datum; ^ HINT: You will need to rewrite or cast the expression. )
> Regards
> Johann
>
> --
>  May grace and peace be yours in abundance through the full knowledge of God
> and of Jesus our Lord!  His divine power has given us everything we need for
> life and godliness through the full knowledge of the one who called us by
> his own glory and excellence.
>                                                     2 Pet. 1:2b,3a

Reply via email to