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

PropertiesToIncludeOnUpdate is ignored when using MySQL #1559

Open
ErikForwerk opened this issue Sep 4, 2024 · 3 comments
Open

PropertiesToIncludeOnUpdate is ignored when using MySQL #1559

ErikForwerk opened this issue Sep 4, 2024 · 3 comments

Comments

@ErikForwerk
Copy link

It seems, that PropertiesToIncludeOnUpdate is gnored when using with MySQL.
The effect is, that all properties are updated in the DB which either leads the foreign keys be deleted due to null-values (in the case of nullable columns) or to an exception, because the constrained is violated due to no element with ID '0' being available (in the case of non nullable FKs).

Of course normal properties will be overwritten with their respective default values too.

All other similar options (i.e. PropertiesToExclude, PropertiesToExcludeOnUpdate, PropertiesToInclude, PropertiesToIncludeOnUpdate) seem to have the same behavior.

PropertiesToIncludeOnUpdate works as expected with MS-SQL, where only properties specified in the options will be updated in the DB.

I have set up an example test project available here:
https://github.com/ErikForwerk/BulkExtensionsUpdateBugExample
(see README.md for some explanation to the project, but it is fairly small straight forward)

I expected to PropertiesToIncludeOnUpdate either exclude/include certain properties when updating entities
or to have the same behavior across all DB implementations.

@ErikForwerk
Copy link
Author

It seems that up until version version 8.0.4 this feature worked.
This problem started with version 8.1.

@kvpt
Copy link
Contributor

kvpt commented Sep 10, 2024

The only change that could have caused this between 8.0.4 and 8.1.0 is in the commit 97432b5.

Don't know why this was changed.
image

@ErikForwerk
Copy link
Author

The method MergeTable seems to build the SQL-command that we observed while debugging our code.

The behavior of the GetColumnList method changed a little bit with the switch from OperationType.Insert to OperationType.InsertOrUpdate - not sure what that did exactly to its result.
But I think the behavior did not change to - somehow - replace the behavior of the different dictionary in the Where clause.

So it it seems, the change of the columns dictionary in the where-clause would explain the issue.
Likewise I guess the issue would be solved when changing the Where-line back.

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

No branches or pull requests

2 participants