Doctrine 1
  1. Doctrine 1
  2. DC-147

In doctrine 1.2 load_data fails with a bogus error when id holders are repeated

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Invalid
    • Affects Version/s: 1.2.0-ALPHA3
    • Fix Version/s: 1.2.0-BETA1
    • Component/s: Data Fixtures
    • Labels:
      None
    • Environment:
      Ubuntu, PHP 5.3, Symfony 1.3-beta, MySQL 5.1

      Description

      Schema fragment:
      Invoice:
      actAs:
      Timestampable: ~
      tableName: invoice
      columns:
      id:
      type: integer(4)
      primary: true
      autoincrement: true
      billingDate:
      type: date
      dueDate:
      type: date
      hostingAccount_id:
      type: integer(4)
      relations:
      invoiceItems:
      class: InvoiceItem
      local: id
      type: many
      foreign: invoice_id
      foreignType: one

      #
      InvoiceItem:
      actAs:
      Timestampable: ~
      tableName: invoiceItem
      columns:
      id:
      type: integer(4)
      primary: true
      autoincrement: true
      name:
      type: string(100)
      quantity:
      type: integer(4)
      cost:
      type: decimal(10)
      scale: 2
      notnull: false
      default: null
      invoice_id:
      type: integer(4)

      With the following fixture fragment:

      Invoice:
      testInvoice01:
      billingDate: "2009-11-11"
      dueDate: "2009-11-16"
      owningAccount: TestAcc01
      invoiceItems:
      invItem01:
      name: TestLine01
      quantity: 2
      cost: 12.99
      invItem02:
      name: TestLine02
      quantity: 1
      cost: -2.50

      testInvoice02:
      billingDate: "2009-11-11"
      dueDate: "2009-11-21"
      owningAccount: TestAcc01
      invoiceItems:
      invItem01:
      name: TestLine03
      quantity: 2
      cost: 12.99
      invItem02:
      name: TestLine04
      quantity: 1
      cost: -2.50

      The reuse of the invItem01 & invItem02 tags - even as children of separate parents causes an error.
      The reported error was very confusing:

      [Doctrine_Connection_Mysql_Exception]
      SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'created_at' cannot be null

      Making the child tags unique fixed the issue.
      The same fixture loaded without problems in Doctrine 1 (I think 1.0.18 but it's not listed in the released versions above).

      1. DC147TestCase.php
        6 kB
        Jason B
      2. DC147TestCase.php
        6 kB
        Jason B

        Activity

        Hide
        Jason B added a comment -

        I've experienced the same bug. We moved from symfony 1.2 to 1.3 for beta testing.

        This example might help as well.
        Team:
        NCAAF-BostonCollege:
        Sport: NCAAF
        name: Boston College Golden Eagles
        logo: boston_college.gif
        Conference: NCAAF-ACC
        Division: NCAAF-ACC-Atlantic
        TeamAlias:
        a1:

        { alias: BOSTON COLLEGE }

        a2:

        { alias: BC }

        NCAAF-FloridaState:
        Sport: NCAAF
        name: Florida State Seminoles
        logo: florida_state.gif
        Conference: NCAAF-ACC
        Division: NCAAF-ACC-Atlantic
        TeamAlias:
        a1:

        { alias: FLORIDA STATE }

        a2:

        { alias: FSU }

        a3:

        { alias: Florida St }

        In 1.0.x we were able to load all of these teams with x number of aliases. In 1.2 when TeamAlias was actAs: Timestampable we got the result as mentioned in the bug description. But when we removed the Timestampable the a1 aliases would load but none of the a2's or a3's...

        Hope that helps. Thanks guys.

        Show
        Jason B added a comment - I've experienced the same bug. We moved from symfony 1.2 to 1.3 for beta testing. This example might help as well. Team: NCAAF-BostonCollege: Sport: NCAAF name: Boston College Golden Eagles logo: boston_college.gif Conference: NCAAF-ACC Division: NCAAF-ACC-Atlantic TeamAlias: a1: { alias: BOSTON COLLEGE } a2: { alias: BC } NCAAF-FloridaState: Sport: NCAAF name: Florida State Seminoles logo: florida_state.gif Conference: NCAAF-ACC Division: NCAAF-ACC-Atlantic TeamAlias: a1: { alias: FLORIDA STATE } a2: { alias: FSU } a3: { alias: Florida St } In 1.0.x we were able to load all of these teams with x number of aliases. In 1.2 when TeamAlias was actAs: Timestampable we got the result as mentioned in the bug description. But when we removed the Timestampable the a1 aliases would load but none of the a2's or a3's... Hope that helps. Thanks guys.
        Hide
        Jason B added a comment -

        When I reverted this changeset:
        http://trac.doctrine-project.org/changeset/6377/branches/1.2/lib/Doctrine/Data/Import.php

        I was able to import all my related children.

        Show
        Jason B added a comment - When I reverted this changeset: http://trac.doctrine-project.org/changeset/6377/branches/1.2/lib/Doctrine/Data/Import.php I was able to import all my related children.
        Hide
        Jason B added a comment - - edited

        Attached a working test case to satisfy this bug. Adapted from:
        http://trac.doctrine-project.org/browser/branches/1.2/tests/Ticket/DC23bTestCase.php
        So this test also tests some of the functionality of:
        http://www.doctrine-project.org/jira/browse/DC-23

        Show
        Jason B added a comment - - edited Attached a working test case to satisfy this bug. Adapted from: http://trac.doctrine-project.org/browser/branches/1.2/tests/Ticket/DC23bTestCase.php So this test also tests some of the functionality of: http://www.doctrine-project.org/jira/browse/DC-23
        Hide
        Jonathan H. Wage added a comment -

        It is required that every key is unique now. I changed your test case and it passes now.

        Show
        Jonathan H. Wage added a comment - It is required that every key is unique now. I changed your test case and it passes now.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            D Ashwood
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: