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

Reverse Join fails to update record #82

Closed
2 tasks done
romaninsh opened this issue Aug 2, 2016 · 1 comment
Closed
2 tasks done

Reverse Join fails to update record #82

romaninsh opened this issue Aug 2, 2016 · 1 comment
Milestone

Comments

@romaninsh
Copy link
Member

romaninsh commented Aug 2, 2016

It appears that the use of $join->id in reveres join is incorrect.

Look at this file: https://github.com/atk4/data/blob/develop/src/Join_SQL.php#L211

With reverse join you are joining like this:

$db->join('contact.user_id');

foreign_field is user_id, and suppose user_id is 2. When you add new record, $join->id is set to lastInsertID:

$this->id = $insert->connection->lastInsertID();

so it holds the value of contact.id, let's say it's 1 for our new record. If you execute delete after, the where() clause can cause deletion of incorrect record:

$delete->where($this->foreign_field, $this->id);

which would render to "where user_id = 1".

  • create failing test-case for this bug
  • implement a fix
@romaninsh romaninsh added this to the 1.0.2 milestone Aug 2, 2016
@romaninsh romaninsh modified the milestones: 1.1.0, 1.0.2, 1.0.3 Aug 10, 2016
@romaninsh romaninsh modified the milestones: 1.1.0, 1.0.3 Aug 25, 2016
@romaninsh
Copy link
Member Author

This should be fixed by #107

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

No branches or pull requests

1 participant