有一个Postgres数据库。有一个带有Foo主键的id表。有一个多对多的表Bar,其中包含一个行,其中包含一个外键,它引用一个不存在的foo对象。其结果是:
ERROR: insert or update on table "Bar" violates foreign key constraint "resu_foo_id_62eaf76ab86870ae_fk_foo_id"
DETAIL: Key (foo_id)=(123) is not present in table "Foo".
如何在外键引用不存在的对象的所有表中获取所有行?
我正在创建事件,并希望将它们捆绑到按标题匹配的合并对象中,因此我创建了一个EventBundle存储库,其中包含这些对象,并根据它注册单个事件,将它们按标题匹配到捆绑包中。
因为我在保存它们时遇到了很多麻烦,所以我已经在本地缓存了它们,这确实有一些帮助,但仍然相当糟糕。
public function registerEvent($event) {
//We are matching with the title of the event so we get that first
$title = $event->getEvTitle();
if(!isset(
在Rails文档中,用于has_one的:dependent的前2个值是:
4.2.2.4 :dependent
Controls what happens to the associated object when its owner is destroyed:
:destroy causes the associated object to also be destroyed
:delete causes the associated object to be deleted directly from the database (so callbacks will n