【问题标题】:How to specify null foreign key in symfony doctrine fixture如何在 symfony 教义夹具中指定空外键
【发布时间】:2011-04-20 00:10:10
【问题描述】:

这是一个 Doctrine 架构:

Device:
  columns:
    name:           { type: string(60), }
    os_version_id:  { type: int(11), notnull: false }
  relations:
    OsVersion:
      foreignAlias: Devices

OsVersion:
  columns:
    version: { type: string(60), fixed: false, notnull: true }

这是一个固定装置:

OSV_ABCD:
  version: ABCD

OSV_DEFG:
  version: DEFG

Device:
  Device_1:
    name: 'My device'
    OsVersion: null

当加载这个夹具时,我得到这个:

Invalid row key specified: (os_version) , referred to in (device) Device_1

如果我将OsVersion: null 更改为OsVersion: OSV_ABCD,它会毫无问题地加载。

【问题讨论】:

    标签: symfony1 null fixtures


    【解决方案1】:

    完全忽略外键行:

    Device:
      Device_1:
        name: 'My device'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-30
      • 1970-01-01
      • 1970-01-01
      • 2016-03-09
      • 1970-01-01
      • 1970-01-01
      • 2023-03-06
      • 1970-01-01
      相关资源
      最近更新 更多