Skip to content

Feature/clean up join messups#73

Merged
DarkSide666 merged 57 commits intodevelopfrom
feature/clean-up-join-messups
Jul 25, 2016
Merged

Feature/clean up join messups#73
DarkSide666 merged 57 commits intodevelopfrom
feature/clean-up-join-messups

Conversation

@romaninsh
Copy link
Copy Markdown
Member

@romaninsh romaninsh commented Jul 25, 2016

Merge #72 and #71 first.

Then pull from "master".

Fixing duplicates in the same field

The recent PR into DSQL atk4/dsql#100 has introduced a side effect. atk4/dsql#102 adds a check resulting in exception when the following is called:

$insert->set('foo', 1);
$insert->set('foo', 2);

As it turns out SQL Join would execute set() when 'foo' is joined field:

$m['foo'] = 'one';
$m['foo'] = 'two';

Also if the field is defined as-is then used in a join, it would cause a similar mess-up. This PR fixes that.

Unloading and changing Join

Another problem was visible if you change the field in the "join" field then load a different record. Join wouldn't reset the changed field and would slap that new value into an unrelated record.

Now when the record is unloaded, join-items are cleaned properly.

Change in joined field only.

Previously when you change no field and call save() it would do nothing. If you only change the field that is join() and call save() it would still do nothing.

Now steps are taken to make sure the joined table is updated correctly.

romaninsh and others added 25 commits July 21, 2016 16:21
$m->save() invokes update with a fixed ID. Also it updates joined
tables separately. Because the record has been loaded successfully
before and will be reloaded after updates (in some cases) at a risk of
failed transaction, we don't have to invoke action here.

Action is more suited for all-set update and if you use joins with
SQLite you're on your own, as it does not support join with update.

Same goes for deletion.
If model is saving field and join is saving on top, we get problem.
No manual tweaking of related values (until we can figure out how to do
it safely, through join)
@DarkSide666 DarkSide666 merged commit fa4ac2d into develop Jul 25, 2016
@DarkSide666 DarkSide666 deleted the feature/clean-up-join-messups branch July 25, 2016 22:35
@romaninsh romaninsh restored the feature/clean-up-join-messups branch August 19, 2016 10:22
@romaninsh romaninsh deleted the feature/clean-up-join-messups branch August 19, 2016 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants