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

PostgreSql: Audit does not work for BulkUpdate #102

Open
ElenaShlykova opened this issue Jan 5, 2022 · 7 comments
Open

PostgreSql: Audit does not work for BulkUpdate #102

ElenaShlykova opened this issue Jan 5, 2022 · 7 comments
Assignees

Comments

@ElenaShlykova
Copy link

ElenaShlykova commented Jan 5, 2022

Hello,
We noticed that the audit does not work correctly with the postgreSQL database.
When updating a record with BulkUpdate, the old value is equal to the new value.

In my example, I am creating a test entity with Value = 'TestValue'. After that, I update the Value property to 'NewValue' and update the record with BulkUpdate. After that, I see that the record in the database has been updated.

         using (var connection = new NpgsqlConnection("Server=localhost; Port=5432; Database=dbname; User Id=sa; Password=123;"))
         {
            var dapperAuditEntries = new List<AuditEntry>();
            var set = connection.UseAuditing(dapperAuditEntries);

            set.BulkInsert(testEntity);
            Console.WriteLine(testEntity.Value);
            **// Output is 'TestValue'**

            testEntity.Value = "NewValue";
            set.BulkUpdate(testEntity);
            Console.WriteLine(testEntity.Value);
            **// Output is 'NewValue'**
         }

The problem is in dapperAuditEntries the old value is equal to the new value:
image
I expect the old value to be 'TestValue'.

Mapping:

            DapperPlusManager.Entity<TestEntity>()
               .Key(x => x.Id, "id")
               .Map(x => x.Value, "value")
               .Table("table");

This works well for mssql.

@JonathanMagnan JonathanMagnan self-assigned this Jan 6, 2022
@JonathanMagnan
Copy link
Member

Hello @ElenaShlykova ,

Thank you for reporting,

My developer will look at it.

Best Regards,

Jon

@karolswdev
Copy link

Hi @JonathanMagnan - have you been able to look into this yet?

@karolswdev
Copy link

Hi @JonathanMagnan - bump :)

@JonathanMagnan
Copy link
Member

Hello @karolswdev ,

Sorry for the long delay,

Unfortunately, there is no good news for this one. Making it work correctly with PostgreSQL requires too many changes for what we can do now. We currently focus our time on supporting and re-write our library for EF Core 7, so that's currently impossible to find enough time to make all the necessary changes for this one.

Best Regards,

Jon

@dpatusb
Copy link

dpatusb commented Oct 14, 2022

Hi @JonathanMagnan,

What is alternative for this ? Can you provide and example ?

@JonathanMagnan
Copy link
Member

Hello @karolswdev , @dpatusb ,

It took us some time but the v5.0.0 has been finally released.

The BulkUpdate and BulkMerge now correctly work with the audit features.

If you have the chance to test it, let us know if everything works as expected.

Best Regards,

Jon

@karolswdev
Copy link

@ElenaShlykova - looks like they've made a major change. Could be a positive impact for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants