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

Fix InsertOrUpdate inserting second record when there are no dirty props #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Itzalive
Copy link

@Itzalive Itzalive commented May 5, 2023

Fixes #18

@jamesholwell
Copy link
Contributor

What would the expected behaviour be when passing in an untracked entity with a valid primary key? For example, decode an entity from post and then try to insert or update it?

In the mists of time, passing in an untracked entity to save was valid - not sure if this is or should be the case nowadays

@Itzalive
Copy link
Author

Itzalive commented May 6, 2023

Currently, if you have a valid existing PK and call Save() without tracking enabled it will do nothing. It only updates the dirty properties and if tracking is not enabled there will be none.

We always fetch a copy from the DB in a POST update and copy over all the values to update it with before calling Save.

Checking for the existence of a PK is not recommended as it is a 'feature' of Dashing 2 that you can insert an entity with a specific PK.

Without doing a call to see if the PK already exists then I felt this was the safest option - it's very unusual to be manually configuring tracking.

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

Successfully merging this pull request may close these issues.

InsertOrUpdate doesn't work for unchanged entities
2 participants