Pyqt6 bug with QSqlRelationalTableModel and Postgresql (version 13)
-
The following code works perfectly with Sqlite3 but not with Postgres. No bug but the returned table is always empty...
self.model = QSqlRelationalTableModel(db=db) self.model.setTable("hr_employee") self.model.setRelation(2, QSqlRelation("Job", "job_id", "name")) self.model.select() self.table.setModel(self.model)if I remove this line, it works !
self.model.setRelation(2, QSqlRelation("Job", "job_id", "name"))I would appreciate any help because I am stuck.
-
How should we know what's wrong when you don't show us e.g. the table schemas and which Qt version you use?
-
@Jelutho said in Pyqt6 bug with QSqlRelationalTableModel and Postgresql (version 13):
QSqlRelation("Job", "job_id", "name")
You showed your schema but it doesn't have a "Job" table which is the first argument of your QSqlRelation.
-
Hello
the code is...
self.model_employee.setRelation(3, QSqlRelation("hr_job", "job_id", "name"))...and it still doesn' work.
@Jelutho
Can you use something like
[override virtual protected]QString QSqlRelationalTableModel::selectStatement() const
to examine what SQL statements are being sent to the database?Meanwhile, your column number has now changed to
3which wouldn't work with the schema you showed, we don't know why. And originally you said the code worked in SQLite, but then you say the table is not actually namedJobbuthr_job. You may be right and there is a Postgresql vs SQLite issue here but you're not very consistent with what you claim/show so it's hard to be sure.