如何在symfony doctrine fixture中指定null外键

时间:2011-04-20 00:10:11

标签: symfony1 null fixtures

这是一个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,则会毫无问题地加载{{1}}。

1 个答案:

答案 0 :(得分:0)

省略外键行完全有效:

Device:
  Device_1:
    name: 'My device'