Important: Please read the Qt Code of Conduct -

Using QSqlRelationalTableModel issue

  • Hi all,

    I use Qt to get an access to PostgreSql DB, but I get a QtSqlError in runtime and can't find more information about it in net.
    I have two tables at DB:

    @CREATE TABLE "session"
    "sessionID" integer NOT NULL,
    "userID" integer NOT NULL,
    "packetsSent" integer,
    "packetsReceive" integer,
    "loginAutorization" boolean NOT NULL,
    "biometricAutorization" boolean NOT NULL,
    "autorizationAttempts" integer NOT NULL,
    CONSTRAINT session_pkey PRIMARY KEY ("sessionID")
    WITH (

    @CREATE TABLE token
    "tokenID" integer NOT NULL,
    "sessionID" integer NOT NULL,
    "generationTime" time without time zone NOT NULL,
    "expiredTime" time without time zone NOT NULL,
    CONSTRAINT token_pkey PRIMARY KEY ("tokenID"),
    CONSTRAINT "token_sessionID_fkey" FOREIGN KEY ("sessionID")
    REFERENCES "session" ("sessionID") MATCH SIMPLE
    WITH (

    I use QSqlRelationalTableModel to get data from DB and QTableView to display it. Relations between tables are coded by QSqlRelationalTableModel::setRelation():

    @model->setRelation(1, QSqlRelation("session", "sessionID", "sessionID"));@

    EditStrategy for model is set to OnManualSubmit.
    Then I change some data in table and try to save it by using QSqlRelationalTableModel::submitAll() I get an error:

    bq. ERROR: column reltblal_1.sessionid does not exist LINE 1: SELECT token."tokenID", relTblAl_1.sessionID, token."generat... ^ QPSQL: Unable to create query

    I have some other tables and get this message for ever table which contain foreign key. The same message is seen even if I don't change anything and try to submit all.
    It's probably can be correlated with "QTBUG-15989": , but I don't sure.
    I'll be happy to receive any comments about this.

Log in to reply