OpenEnergyPlatform/oedialect

Query to data containing the symbol ' results in faulty json

Closed this issue · 1 comments

@Ludee created a query for two structurally identical tables. It succeeds for one and fails for another. @coroa neatly narowed the problem down for us. The issue also concisely describes the problem

For reference: OpenEnergyPlatform/saio#4

@MGlauer this is high priority for us. How quickly could a fix be implemented?

Just for good measure, I'm attaching the query files again here: oep_mastr_query.zip.

The error occurs because quotes are not escapes. I would suggest to include something like this:
oedialect/engine.py change line 177 to

try:
  yield json.loads(line.decode('utf8').replace("'", '"'))
except:
  yield json.loads(line.decode('utf8').replace("'", '\\"'))

@MGlauer are you ok with this? or would simply changing to yield json.loads(line.decode('utf8').replace("'", '\\"') without the exception be enough. I tested both and it worked just fine.