1

我在 symfony 1.4 和学说 1.2 中遇到了一个奇怪的错误。我的模式似乎很正常。但是每当我执行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
4

1 回答 1

0

“如果我将 default_edition_id 字段的 notnull 设置为 false,它实际上只是 null”。在这句话中,“它”指的是什么?Notnull 表示该字段的值“null”是可接受的,而不是它的值将始终为 null,如果这是您的意思。

于 2010-08-09T16:20:14.080 回答