Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PopulateMergeMatch does not work as expected #15

Open
nebucaz opened this issue Jan 1, 2016 · 3 comments
Open

PopulateMergeMatch does not work as expected #15

nebucaz opened this issue Jan 1, 2016 · 3 comments

Comments

@nebucaz
Copy link

nebucaz commented Jan 1, 2016

I expected to be able to update/merge existing records using PopulateMergeMatch as described in the documentation based. I've written a simple example like follows:

_config/config.yml

Member:
  test:
    Email: "[email protected]"
    Password: "password"
    PopulateMergeMatch:
      - Email

I expected the Populate task to merge with the existing record on consecutive runs of the populate task but it throws a validation error:

ERROR [User Error]: Uncaught ValidationException: Can't overwrite existing member #1 with identical identifier (Email = [email protected]))
IN GET /dev/tasks/PopulateTask
Line 852 in framework/security/Member.php

I've posted the sample-project here https://github.com/nebucaz/sspopulate


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@Leapfrognz
Copy link

The issue is that $obj = $blueprint->createObject($identifier, $data, $this->fixtures); actually writes the new object. This cant happen if the original being updated a unique index, such as Email with members. Unfortunately FixtureBlueprint is a core class.

@jakxnz
Copy link
Contributor

jakxnz commented Nov 3, 2020

Can confirm, this is effecting any record with a unique index value duplicated by populate data.

I was expecting the record data to merge without conflicts.

@jonom
Copy link

jonom commented Feb 15, 2023

I hit this problem as well so I tried the example from the ReadMe:

SilverStripe\Security\Member:
  admin:
    ID: 1
    Email: "[email protected]"
    PopulateMergeMatch:
      - 'ID'
      - 'Email'

It doesn't throw the same error but it also doesn't create a member. There is no Member with an ID of 1 or an email of [email protected].

I also get a [Notice] Undefined index: MyRelationID when trying to use a has_one in PopulateMergeMatch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants