Skip to content

PostgreSql: Audit does not work for BulkUpdate #102

@ElenaShlykova

Description

@ElenaShlykova

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.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions