3

So I just started to write my API, and came across this bug:

On creating user that has unique CONSTRAINT twice, There is exception returned, but the node is still being created!

The CONSTRAINT is on "User:access_token" property, and I'm using the following code:

try {
    $userAttributes = [
        "email" => $request->email,
        "access_token"  =>  'aaaa',
        "facebook_id"   =>  'bbbb'
    ];
    $user = new User($userAttributes);
    $user->save();
}catch (Exception $e){}

Any help please?

Itay Elkouby
  • 344
  • 1
  • 15
  • Can you please run `:schema` in your Neo4j browser to make sure the constraints were created properly? Seems like the issue is beyond the OGM. – mulkave Oct 04 '16 at 09:06
  • @Mulkave Here is the output from the schema command: Indexes ON :User(email) ONLINE (for uniqueness constraint) ON :User(access_token) ONLINE (for uniqueness constraint) Constraints ON (user:User) ASSERT user.access_token IS UNIQUE ON (user:User) ASSERT user.email IS UNIQUE – Itay Elkouby Oct 04 '16 at 21:48

1 Answers1

1

This issue is due to the underlying driver using the REST API instead of executing a Cypher query. As a workaround (at the time of this answer) there's a NeoEloquent branch 1.5-dev that uses a different driver and it will be used to run Cypher against the database. This branch is still under development but currently fully backward-compatible.

To install it add the version dev-1.5-dev to your composer.json file and run composer update vinelab/neoeloquent.

mulkave
  • 831
  • 1
  • 10
  • 22