Skip to content

Bug: Wrong schema detection in case of composite keys #485

Open
@EmilianoMusso

Description

@EmilianoMusso

Testing RepoDb on SQL Server and having composite key tables, i've run into the following behaviour. RepoDb cannot look out the complete composite key, using only the first field of it to determine the primary key. That results in total deletion of records which have equality on the determined field.

Here follows a sample code to replicate behaviour (TSQL + C#) :

   CREATE TABLE [dbo].[Product](
      CompanyCode VARCHAR(2) DEFAULT '' NOT NULL,
      ProductCode VARCHAR(25) DEFAULT '' NOT NULL,
      Description VARCHAR(50) DEFAULT '' NOT NULL,
      PRIMARY KEY(CompanyCode, ProductCode)
   )

    // Sample class
    public class Product
    {
        // First field of primary key
        public string CompanyCode { get; set; }
        // Second field of primary key
        public string ProductCode { get; set; }
        public string Description { get; set; }
    }

    // Code to replicate behaviour
    var p = new Product()
                {
                    CompanyCode = "CC",
                    ProductCode = "Product_01",
                    Description = "FOR TEST USE"
                };
   // The following command result in complete deletion of all records having CompanyCode = "CC", without considering ProductCode
   connection.Delete<Product>(p);

Thank you

Metadata

Metadata

Assignees

Labels

known-bugA known-bug that has been a part of the release.limitationA request or a feature that is cannot be supported

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions