#6 resultsdb throws sqlalchemy errors when used with postgresql
Closed: Fixed None Opened 9 years ago by tflink.

When I try using resultsdb with postgres, I get sqlalchemy errors like:

LINE 1: ...me, end_time, ref_url, name) VALUES ('SCHEDULED', 0, 0, 'htt...
^
HINT: You will need to rewrite or cast the expression.
'INSERT INTO job (status, start_time, end_time, ref_url, name) VALUES(%(status)s, %(start_time)s, %(end_time)s, %(ref_url)s, %(name)s) RETURNING job.id' {'status': 'SCHEDULED', 'ref_url': 'http://example.com/someref', 'end_time': 0, 'start_time': 0, 'name': None}

Fix the issues with resultsdb schema so that it works with postgres


This ticket had assigned some Differential requests:
D61

The root issue appears to be in resultsdb/models/results.py:
class Job(db.Model, DBSerialize):

  id = db.Column(db.Integer, primary_key = True)
  status = db.Column(db.Enum(*JOB_STATUS, name='jobstatus'))
  start_time = db.Column(db.DateTime, default = 0)
  end_time = db.Column(db.DateTime, default = 0)
  ref_url = db.Column(db.Text)
  name = db.Column(db.Text)

postgres doesn't like the default of 0 for the two time columns. I suspect that removing the default and having the default as null would work here but I only tested it with sqlite.

Please test this with postgres and make sure that there are no other schema compatibility issues that worked with mysql.

Closed by commit rRSDBba16b5c0e56c.

Login to comment on this ticket.

Metadata