This is an archive of the discontinued LLVM Phabricator instance.

[LNT] Python 3 support: fix storage of json data as BLOB
ClosedPublic

Authored by thopre on Oct 10 2019, 8:41 AM.

Details

Summary

Machine and Run tables store JSON as binary data in their Parameters
column. However, JSON is inserted as text data in several places,
causing problem when SQLAlchemy reads it back since it expects binary
data but receives text, which Python3 throws an exception for.

2 constructs are responsible for inserting JSON as text:

  1. json.dumps() method is used in several places to convert a dictionary to JSON which returns it as text. This commit adds an encoding step to UTF-8 since it is the recommended encoding for JSON.
  1. One of the insertion with a JSON Parameters column in lnt_db_create.sql is missing a cast to BLOB. This commit adds the missing cast.

Event Timeline

thopre created this revision.Oct 10 2019, 8:41 AM
thopre updated this revision to Diff 224561.Oct 11 2019, 4:10 AM

Add more cases of missing CAST to BLOB

From where can I get schema for this database you are inserting to ?

PrzemekWirkus accepted this revision.Dec 5 2019, 7:28 AM

LGTM

Ah, DB schema is just above the insert. Silly me!

This revision is now accepted and ready to land.Dec 5 2019, 7:28 AM
thopre closed this revision.Dec 5 2019, 7:37 AM