完整性约束违规:1048列不能为空错误

时间:2010-08-09 09:19:19

标签: symfony1 doctrine symfony-1.4 doctrine-1.2

我在使用doctrine 1.2的symfony 1.4中遇到了一个奇怪的错误。我的模式似乎很正常。但每当我执行doctrine:build --all --no-confirmation --and-load任务时,它都会输出错误SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'default_edition_id' cannot be null。如果我为default_edition_id字段设置notnull为false,它实际上只是null。任何人都可以帮我解决我可能缺少的事情吗?

这是我的架构文件(chapter.yml):

Chapter:
  actAs:
    Timestampable: ~
    Versionable:
      versionColumn: version
      className: %CLASS%Version
    SoftDelete: ~
  columns:
    name: string
    chapter_number: { type: integer, notnull: true }
    series_id: { type: integer, notnull: true }
    default_edition_id: { type: integer, notnull: true }
    disabled:
      type: enum
      values: [1, 0]
      default: 0
      notnull: true
  relations:
    DefaultEdition:
      local: default_edition_id
      class: Edition
      foreign: id
      foreignAlias: DefaultChapter
      foreignType: one
      type: one
#      onDelete: CASCADE
    Series:
      local: series_id
      foreign: id
      onDelete: CASCADE
    Editions:
      type: many
      class: Edition
      local: id
      foreign: chapter_id

和我的版本架构(edition.yml):

Edition:
  actAs:
    Timestampable: ~
    Sluggable:
       fields: [name]
    Versionable:
      versionColumn: version
      className: %CLASS%Version
    SoftDelete: ~
  columns:
    name: string
    completed_reads: { type: integer, notnull: true, default: 0}
    views: { type: integer, notnull: true, default: 0 }
    language_id: { type: integer, notnull: true }
    chapter_id: { type: integer, notnull: true }
    disabled:
      type: enum
      values: [1, 0]
      default: 0
      notnull: true
  relations:
    Pages:
      type: many
      class: Page
      local: id
      foreign: edition_id
    Language:
      local: language_id
      foreign: id
      type: one
      onDelete: CASCADE
    Chapter:
      local: chapter_id
      foreign: id
      onDelete: CASCADE

灯具:

Chapter:
  bakuman_chapter:
    Series: bakuman
    chapter_number: 86
    DefaultEdition: edition_1
  bakuman_chapter2:
    Series: bakuman
    DefaultEdition: edition_2
    chapter_number: 90

Edition:
  edition_1:
    name: edition 1
    Chapter: bakuman_chapter
    ScanlationGroup: [group_1, group_2, group_3]
    Language: english
  edition_2:
    name: edition 2
    Chapter: bakuman_chapter2
    ScanlationGroup: [group_4]
    Language: japanese
  edition_2_2:
    name: edition 2_2
    Chapter: bakuman_chapter2
    ScanlationGroup: [group_4, group_2]
    Language: english

1 个答案:

答案 0 :(得分:0)

“如果我为default_edition_id字段设置notnull为false,它实际上只是为空”。在这句话中,“它”是指吗? Notnull意味着该字段可以接受值'null',而不是它的值总是为null,如果这是你的意思。