In addition, I have installed and using psycopg2 driver.

I still run into the error:

<class 'psycopg2.ProgrammingError'>(column "json_string__tmp" is of type 
json but expression is of type text
LINE 1: UPDATE "data_table" SET "json_string__tmp"="json_string"...
                                                       ^
HINT:  You will need to rewrite or cast the expression.
)


And this is the traceback (psycopg2):
Traceback (most recent call last):
  File "/Users/web2py/gluon/restricted.py", line 216, in restricted
    exec(ccode, environment)
  File "/Users/web2py/applications/groupbuys/models/tables.py", line 85, in 
<module>
    format=lambda r: '%s %s %s' % (r.condition.name, r.name, r.level)
  File "/Users/web2py/gluon/packages/dal/pydal/base.py", line 587, in 
define_table
    table = self.lazy_define_table(tablename, *fields, **args)
  File "/Users/web2py/gluon/packages/dal/pydal/base.py", line 621, in 
lazy_define_table
    polymodel=polymodel)
  File "/Users/web2py/gluon/packages/dal/pydal/adapters/base.py", line 778, 
in create_table
    return self.migrator.create_table(*args, **kwargs)
  File "/Users/web2py/gluon/packages/dal/pydal/migrator.py", line 297, in 
create_table
    fake_migrate=fake_migrate
  File "/Users/web2py/gluon/packages/dal/pydal/migrator.py", line 417, in 
migrate_table
    self.adapter.execute(sub_query)
  File "/Users/web2py/gluon/packages/dal/pydal/adapters/__init__.py", line 
67, in wrap
    return f(*args, **kwargs)
  File "/Users/web2py/gluon/packages/dal/pydal/adapters/base.py", line 416, 
in execute
    rv = self.cursor.execute(command, *args[1:], **kwargs)
ProgrammingError: column "json_string__tmp" is of type json but expression 
is of type text
LINE 1: UPDATE "data_table" SET "json_string__tmp"="json_string"...
                                                       ^
HINT:  You will need to rewrite or cast the expression.

I have tried to cast the expression, again, manually, in psql, but the 
column type just keeps reverting to 'text'.

Thank you.


On Thursday, July 6, 2017 at 11:53:39 AM UTC+8, lyn2py wrote:
>
> what do you mean by " manually altered the type to JSON"?  
>
>
> I meant that I logged into the Postgresql DB and ran a command to cast the 
> right type, i.e. "json", for that particular column.
>
>
> On Thursday, July 6, 2017 at 4:49:14 AM UTC+8, Massimo Di Pierro wrote:
>>
>> what do you mean by " manually altered the type to JSON"? Anyway, please 
>> use psycopg2 instead of pg8000.
>>
>> On Tuesday, 4 July 2017 04:03:00 UTC-5, lyn2py wrote:
>>>
>>> I'm using Postgresql, with the pg8000 adapter.
>>>
>>> One of the fields I have is of 'json' type
>>>
>>>         Field('json_string','json'),
>>>
>>>
>>> And each time I restart the web2py server, this error will show one 
>>> time. Refreshing the page the second time makes it go away:
>>>
>>> ProgrammingError: (u'ERROR', u'ERROR', u'42804', u'column 
>>> "json_string__tmp" is of type json but expression is of type text', u'You 
>>> will need to rewrite or cast the expression.', u'48', u'parse_target.c', 
>>> u'540', u'transformAssignedExpr', u'', u'')
>>>
>>>
>>> I checked the db itself and the schema says:
>>> Column = json_string
>>> Type = text
>>>
>>> So I did a search and manually altered the type to JSON. After restart, 
>>> no errors! It was good.
>>> BUT... subsequent restarting of the server brought back the error. So I 
>>> checked the db again and the Type is changed back to 'text' again
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>

-- 
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.

Reply via email to