Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Using QSqlRelationalTableModel issue

    General and Desktop
    1
    1
    1465
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • E
      Einior last edited by

      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 (
      OIDS=FALSE
      );@

      @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
      ON UPDATE NO ACTION ON DELETE NO ACTION
      )
      WITH (
      OIDS=FALSE
      );@

      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":https://bugreports.qt.nokia.com/browse/QTBUG-15989 , but I don't sure.
      I'll be happy to receive any comments about this.

      1 Reply Last reply Reply Quote 0
      • First post
        Last post