[odb-users] Update the id of an object which has a relation with
the other object
علی دانش
adanesh at noornet.net
Tue Apr 26 01:21:20 EDT 2016
Hi Boris,
> Sounds like a job for ON UPDATE CASCADE. I think this should work:
> #pragma db value_options("ON UPDATE CASCADE")
> QList<std::shared_ptr<OTHER_CLASS>> m_otherClassList;
It doesn't work for me.
Error message: 1: near "UPDATE": syntax error
I checked the generated query. I think it is incorrect.
CREATE TABLE "TagIndex_keywords" (
"object_id" INTEGER NOT NULL,
"index" INTEGER NOT NULL,
"value" INTEGER NULL ON UPDATE CASCADE,
CONSTRAINT "object_id_fk"
FOREIGN KEY ("object_id")
REFERENCES "TagIndex" ("id")
ON DELETE CASCADE,
CONSTRAINT "value_fk"
FOREIGN KEY ("value")
REFERENCES "KeywordIndex" ("id")
DEFERRABLE INITIALLY DEFERRED)
Ali
________________________________________
From: Boris Kolpackov <boris at codesynthesis.com>
Sent: Tuesday, April 19, 2016 6:53 PM
To: علی دانش
Cc: odb-users at codesynthesis.com
Subject: Re: [odb-users] Update the id of an object which has a relation with the other object
Hi Ali,
> I want to update the id of an object which has a relation with the
> other object.
Sounds like a job for ON UPDATE CASCADE. I think this should work:
#pragma db value_options("ON UPDATE CASCADE")
QList<std::shared_ptr<OTHER_CLASS>> m_otherClassList;
Or, if you had a pointer instead of a container of pointers:
#pragma db options("ON UPDATE CASCADE")
std::shared_ptr<OTHER_CLASS> m_otherClass;
Boris
More information about the odb-users
mailing list