zzzprojects / Dapper-Plus

Dapper Plus - High-Efficient Bulk Actions (Insert, Update, Delete, and Merge) for .NET
https://dapper-plus.net/
380 stars 84 forks source link

UpdateMatchedAndConditionNames in BulkOperation are ignored for PostgreSql #103

Closed nothings-more closed 2 years ago

nothings-more commented 2 years ago

Hello,

I'm trying to extend bulk update operation using UpdateMatchedAndConditionNames , but looks like this setting is not affect resulting SQL generated for PostgreSql provider, while it works for SqlServer provider as expected.

For example, consider having an entity with 2 properties: Id (key) and Version. Following code

connection.UseBulkOptions(bulkOperation =>
            {
                bulkOperation .UpdateMatchedAndConditionNames = new List<string> { "Version" };
            }).BulkUpdate(new[] { entity });

produces MERGE statement for SqlServer provider, with expected additional condition for "Version", i.e. in SqlServer bulk update will be performed only for those rows in DB where "Id" and "Version" are equal to corresponding properties of entity to update.

For PostgreSql provider, though, the same C# code produces UPDATE with only "Id" comparison included in WHERE clause, i.e. comparison of "Version" is ignored.

I've sent a sample project with ability to test both providers to info@zzzprojects.com

Also, looks like there is a similar issue for MergeMatchedAndConditionNames property for bulk operations

Please let me know if you need any additional info on the issue.

Thanks in advance, Alex

JonathanMagnan commented 2 years ago

Helloo @nothings-more ,

The v4.0.21 has been released.

Could you try it and confirm us that everything is now working for the option UpdateMatchedAndConditionNames?

Best Regards,

Jon

nothings-more commented 2 years ago

@JonathanMagnan , yes, looks like the issue is fixed in 4.0.21 Thank you

nothings-more commented 2 years ago

Hello,   Yes, looks like the issue is fixed in 4.0.21 Thank you   Best regards, Alex

Среда, 12 января 2022, 17:35 +03:00 от Jonathan Magnan @.***>:     Helloo @nothings-more , The v4.0.21 has been released. Could you try it and confirm us that everything is now working for the option UpdateMatchedAndConditionNames? Best Regards, Jon — Reply to this email directly, view it on GitHub , or unsubscribe . Triage notifications on the go with GitHub Mobile for iOS or Android . You are receiving this because you were mentioned. Message ID: <zzzprojects/Dapper-Plus/issues/103/1011107759 @ github . com>