PublicaMundi / labs.geodata.gov.gr

Manage the beta deployment of PublicaMundi on labs.geodata.gov.gr
2 stars 1 forks source link

Fix problematic handling of i18n strings at datastore api level. #144

Closed drmalex07 closed 8 years ago

drmalex07 commented 8 years ago

Several datastore api actions don't seem to handle i18n strings properly. The following is a typical backtrace for an SQL-like datastore-backed query.

Query:

GET /api/action/datastore_search_sql?sql=SELECT%20*%20from%20%22bfcc83a7-65df-48c4-9457-f6c4daaf8003%22%20WHERE%20comments%20LIKE%20%27%CE%B4%CE%B9%CE%B1%CF%86%CE%AE%CE%BC%CE%B9%CF%83%CE%B7%27

Backtrace:

File '/usr/local/ckan/default/pyenv/src/ckan/ckan/controllers/api.py', line 189 in action
  result = function(context, request_data)
File '/usr/local/ckan/default/pyenv/src/ckan/ckan/logic/__init__.py', line 419 in wrapped
  result = _action(context, data_dict, **kw)
File '/usr/local/ckan/default/pyenv/src/ckan/ckan/logic/__init__.py', line 535 in wrapper
  return action(context, data_dict)
File '/usr/local/ckan/default/pyenv/src/ckan/ckanext/datastore/logic/action.py', line 387 in datastore_search_sql
  result = db.search_sql(context, data_dict)
File '/usr/local/ckan/default/pyenv/src/ckan/ckanext/datastore/db.py', line 1189 in search_sql
  table_names = datastore_helpers.get_table_names_from_sql(context, sql)
File '/usr/local/ckan/default/pyenv/src/ckan/ckanext/datastore/helpers.py', line 41 in get_table_names_from_sql
  'EXPLAIN (FORMAT JSON) {0}'.format(sql)).fetchone()
UnicodeEncodeError: 'ascii' codec can't encode characters in position 74-82: ordinal not in range(128)