Skip to content

Improve joined model update/delete.#71

Merged
DarkSide666 merged 4 commits intodevelopfrom
feature/minor-improvements-and-cleanups
Jul 25, 2016
Merged

Improve joined model update/delete.#71
DarkSide666 merged 4 commits intodevelopfrom
feature/minor-improvements-and-cleanups

Conversation

@romaninsh
Copy link
Copy Markdown
Member

No description provided.

$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.
@romaninsh
Copy link
Copy Markdown
Member Author

Current problem. $m->delete() and $m->save() rely on action('update') and
action('delete'). Those are not really compatibel anymore.

Single-record save() and delete() are properly augmented by Join_SQL to ensure
that related entities are deleted. More importantly, it might attempt to reload record
after to make sure it is within the same set.

$m->save() invokes update with a fixed ID. Iit 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.

With this PR Persistence_SQL will no longer use action for update/delete but will instead create a basic query. This solves prolbems:

  • ID field update
  • updating records in joined tables
  • updating records that are duplicated across joined tables
  • deleting records with condition on joined table field

(test-scripts for the above cases are not supplied)

@DarkSide666 DarkSide666 merged commit bfc16ee into develop Jul 25, 2016
@DarkSide666 DarkSide666 deleted the feature/minor-improvements-and-cleanups branch July 25, 2016 13:09
@romaninsh romaninsh restored the feature/minor-improvements-and-cleanups branch August 19, 2016 10:22
@romaninsh romaninsh deleted the feature/minor-improvements-and-cleanups 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