Re: [GSoC][New Feature] Editable and Read-only Columns

Yosry Muhammad <[email protected]>
Newsgroups gmane.comp.db.postgresql.pgadmin.devel
Message-ID <CAFSMqn_7NQ4MFajE=93g6L3x9jngoCyiJYWYTCdwpMyFZxqBNA@mail.gmail.com>
 I updated the patch for backwards compatibility anyway.

On Fri, Aug 23, 2019 at 10:45 AM Dave Page <[email protected]> wrote:

>
>
> On Fri, Aug 23, 2019 at 9:43 AM Yosry Muhammad <[email protected]> wrote:
>
>> Hi Aditya,
>>
>> On Fri, Aug 23, 2019 at 7:33 AM Aditya Toshniwal <
>> [email protected]> wrote:
>>
>>> Hi Yosry,
>>>
>>> The previously mentioned issues seems to be fixed. Below are few issues:
>>> 1) On Python 2.7, I get below error when opening query tool:
>>> 2019-08-23 10:49:09,329: ERROR flask.app: Object of type buffer is not
>>> JSON serializable
>>> Traceback (most recent call last):
>>>   File
>>> "/Users/adityatoshniwal/venv/pypg27/lib/python2.7/site-packages/flask/app.py",
>>> line 1813, in full_dispatch_request
>>>     rv = self.dispatch_request()
>>>   File
>>> "/Users/adityatoshniwal/venv/pypg27/lib/python2.7/site-packages/flask/app.py",
>>> line 1799, in dispatch_request
>>>     return self.view_functions[rule.endpoint](**req.view_args)
>>>   File
>>> "/Users/adityatoshniwal/venv/pypg27/lib/python2.7/site-packages/flask_login/utils.py",
>>> line 261, in decorated_view
>>>     return func(*args, **kwargs)
>>>   File
>>> "/Users/adityatoshniwal/projects/pgadmin4/web/pgadmin/tools/sqleditor/__init__.py",
>>> line 1544, in get_query_history
>>>     return QueryHistory.get(current_user.id, trans_obj.sid, conn.db)
>>>   File
>>> "/Users/adityatoshniwal/projects/pgadmin4/web/pgadmin/tools/sqleditor/utils/query_history.py",
>>> line 21, in get
>>>     'result': [rec.query_info for rec in result]
>>>   File
>>> "/Users/adityatoshniwal/projects/pgadmin4/web/pgadmin/utils/ajax.py", line
>>> 75, in make_json_response
>>>     separators=(',', ':'), encoding=encoding),
>>>   File
>>> "/Users/adityatoshniwal/venv/pypg27/lib/python2.7/site-packages/simplejson/__init__.py",
>>> line 399, in dumps
>>>     **kw).encode(obj)
>>>   File
>>> "/Users/adityatoshniwal/venv/pypg27/lib/python2.7/site-packages/simplejson/encoder.py",
>>> line 296, in encode
>>>     chunks = self.iterencode(o, _one_shot=True)
>>>   File
>>> "/Users/adityatoshniwal/venv/pypg27/lib/python2.7/site-packages/simplejson/encoder.py",
>>> line 378, in iterencode
>>>     return _iterencode(o, 0)
>>>   File
>>> "/Users/adityatoshniwal/projects/pgadmin4/web/pgadmin/utils/ajax.py", line
>>> 30, in default
>>>     return json.JSONEncoder.default(self, obj)
>>>   File
>>> "/Users/adityatoshniwal/venv/pypg27/lib/python2.7/site-packages/simplejson/encoder.py",
>>> line 273, in default
>>>     o.__class__.__name__)
>>> TypeError: Object of type buffer is not JSON serializable
>>>
>>
>> This error exists on the master branch on Python 2.7, it is not caused by
>> the patch. It is also not a regression of my previous Query History
>> Enhancement patch, I checked.
>>
>>
>>>
>>> 2) The patch is not compatible with older pyscopg2 (2.7.7). I get below
>>> error in View/Edit data.
>>> [image: Screenshot 2019-08-23 at 10.53.30.png]
>>> 2019-08-23 10:53:12,020: ERROR flask.app: 'table_column'
>>> Traceback (most recent call last):
>>>   File
>>> "/Users/adityatoshniwal/venv/pypg35/lib/python3.5/site-packages/flask/app.py",
>>> line 1813, in full_dispatch_request
>>>     rv = self.dispatch_request()
>>>   File
>>> "/Users/adityatoshniwal/venv/pypg35/lib/python3.5/site-packages/flask/app.py",
>>> line 1799, in dispatch_request
>>>     return self.view_functions[rule.endpoint](**req.view_args)
>>>   File
>>> "/Users/adityatoshniwal/venv/pypg35/lib/python3.5/site-packages/flask_login/utils.py",
>>> line 261, in decorated_view
>>>     return func(*args, **kwargs)
>>>   File
>>> "/Users/adityatoshniwal/projects/pgadmin4/web/pgadmin/tools/sqleditor/__init__.py",
>>> line 435, in poll
>>>     columns = trans_obj.get_columns_types(conn)
>>>   File
>>> "/Users/adityatoshniwal/projects/pgadmin4/web/pgadmin/tools/sqleditor/command.py",
>>> line 688, in get_columns_types
>>>     table_oid=table_oid)
>>>   File
>>> "/Users/adityatoshniwal/projects/pgadmin4/web/pgadmin/tools/sqleditor/utils/get_column_types.py",
>>> line 38, in get_columns_types
>>>     if row['oid'] == col['table_column']:
>>> KeyError: 'table_column'
>>>
>>
>> I recall Dave mentioning that it is okay to use psycopg 2.8+ features and
>> that it was a requirement of pgAdmin 4 now (clearly mentioned in
>> requirements.txt too).
>>
>
> I did - then we had the whole table_oid issue on Debian/Ubuntu :-(
>
>
>> However, I updated the patch for backwards compatibility. Please find an
>> updated patch attached.
>>
>>
>> --
>> *Yosry Muhammad Yosry*
>>
>> Computer Engineering student,
>> The Faculty of Engineering,
>> Cairo University (2021).
>> Class representative of CMP 2021.
>> https://www.linkedin.com/in/yosrym93/
>>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


-- 
*Yosry Muhammad Yosry*

Computer Engineering student,
The Faculty of Engineering,
Cairo University (2021).
Class representative of CMP 2021.
https://www.linkedin.com/in/yosrym93/
Screenshot 2019-08-23 at 10.53.30.png (image/png, 74.9 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.