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. UNIQUE CONSTRAINT FAILED on submitAll()
Forum Updated to NodeBB v4.3 + New Features

UNIQUE CONSTRAINT FAILED on submitAll()

Scheduled Pinned Locked Moved Unsolved General and Desktop
qsqlqsqltablemodelsqlite3uniqueqsqlrelationalt
1 Posts 1 Posters 340 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.
  • D Offline
    D Offline
    dave997
    wrote on last edited by dave997
    #1

    Hi there, I'm experiencing a rather annoying problem.

    Briefly summarized, I have a SQLite3 table with UNIQUE constraint applied over 2 integer fields.
    As of now, I'm populating such table with 8 rows using all combinations of ([1-2], [1-4]) for fields A and B respectively. So far, so good.

    Problems arise whenever I try to swap rows (that means, reassigning those 2 fields among the 8 rows): even if I check not to make duplicates and the table looks good, submitAll() fails returning UNIQUE CONSTRAINT FAILED.
    I believe this has to do with the way submitAll() works, which probably tries to update each line individually hence obviously creating a duplicate. If I were to write SQL I would obviously use an INSERT OR REPLACE statement.

    I wonder if there's anything I can do to stick with QSql classes and avoid converting a ton of code into SQL statements...

    Thank you.

    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