Open jmartinm opened 7 years ago
@jacquerie can you add some pointers to parts of the code that could benefit from this change?
can you add some pointers to parts of the code that could benefit from this change?
In general, every time we import current_search_client
we are doing some query so general that it can't be expressed by one of the Search classes, therefore we should be suspicious.
BTW we don't necessarily need to drop to Postgres' SQL dialect for this, SQLAlchemy has an abstraction on top of it (it even supports path traversal): http://docs.sqlalchemy.org/en/latest/dialects/postgresql.html#sqlalchemy.dialects.postgresql.JSON
For reference: the version of PostgreSQL that is currently available at CERN is 9.4.5 so we need to check which JSON operators are each time available low-level.
I.e.: https://www.postgresql.org/docs/9.4/static/functions-json.html and https://www.postgresql.org/docs/9.4/static/datatype-json.html
has anything been done towards this @jmartinm ?
In situations where some Python code needs to retrieve some records, modify them and then save them in the database we should directly use PostgreSQL capability to query the
json
column inrecords_metadata
to ensure consistency, instead of first querying ES and then retrieving the records from the database.Since the
json
column is defined asjson
(and notjsonb
) we cannot make use of some operators but the ones available forjson
might be enough (see https://www.postgresql.org/docs/9.5/static/functions-json.html)An abstraction should be created with an API to retrieve records from db.