Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Using QSqlRelationalTableModel issue
Qt 6.11 is out! See what's new in the release blog

Using QSqlRelationalTableModel issue

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.8k Views 1 Watching
  • 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 Offline
    E Offline
    Einior
    wrote on last edited by
    #1

    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
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved