Skip to content

fixtures:load - if the same model is defined twice, data is replaced #163

Closed
c33s opened this Issue Jul 2, 2012 · 8 comments

3 participants

@c33s
c33s commented Jul 2, 2012

after my latest propel update, the load fixtures are somehow broken.

it looks like defining a model twice (in two different files or also in the same file defining the model twice) leads to a replacement of the previous defined data.

before the update it works without a problem.

10_fixtures.yml:

Acme\TimeBundle\Model\Schedule\Foo:
    foo1:
        title:                      foobar1
        timetable_id:               bar_default

Acme\TimeBundle\Model\Schedule\Bar:
    bar_default:
        title:                      My Title Default

    bar_special:
        title:                      My Title Special

20_fixtures.yml:

Acme\TimeBundle\Model\Schedule\Bar:
    example_bar_1:
        title:                      My Title Example 1

    example_bar_2:
        title:                      My Title Example 2

the definition above worked before the update and leads now to a:

[Propel] Exception

  The object "bar_default" from class "Acme\TimeBundle\Model\Schedule\Bar" is not defined in your data file.

defining it like that:

10_fixtures.yml:

Acme\TimeBundle\Model\Schedule\Foo:
    foo1:
        title:                      foobar1
        timetable_id:               bar_default

Acme\TimeBundle\Model\Schedule\Bar:
    bar_default:
        title:                      My Title Default

    bar_special:
        title:                      My Title Special

    example_bar_1:
        title:                      My Title Example 1

    example_bar_2:
        title:                      My Title Example 2

works.

@willdurand
Propel member

mmh weird, but not impossible. Let's setup a test for that. Could you do that?

@c33s
c33s commented Jul 2, 2012

will see what i can do.

@c33s
c33s commented Jul 2, 2012

maybe you can point the right direction where to add the test?

@willdurand
Propel member

@c33s already done by @havvg, look at his fix ;)

@havvg
Propel member
havvg commented Jul 2, 2012

The only thing, which will not work (as per definition of YAML): defining the same model twice in the same file. In YAML this means overriding the previous content.

@havvg
Propel member
havvg commented Jul 2, 2012

Example on previous comment (one file):

Acme\TimeBundle\Model\Schedule\Foo:
    foo1:
        title:                      foobar1
        timetable_id:               bar_default

Acme\TimeBundle\Model\Schedule\Foo:
    foo2:
        title:                      foobar2
        timetable_id:               bar_default

Acme\TimeBundle\Model\Schedule\Bar:
    bar_default:
        title:                      My Title Default

    bar_special:
        title:                      My Title Special

foo1 will not exist.

@c33s
c33s commented Jul 2, 2012

thanks for the fix and thanks for the good example on where to add the test :)

defining the same model twice in the same file

as far as i know yml, this should also work. there is the "---" seperator which makes this possible

Multiple documents can exist in a single file/stream and are separated by "---"
https://en.wikipedia.org/wiki/Yml

but i know what you wanted me to tell.

@willdurand
Propel member

Ok, let me close this issue then. If the --- separator doesn't work, it's a problem related to the Symfony2 Yaml component anyway ;)

@willdurand willdurand closed this Jul 3, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.