nsabiyera / Oak

Frictionless development for ASP.NET MVC single page web apps. Prototypical and dynamic capabilities brought to C#.
http://amirrajan.github.com/Oak
MIT License
6 stars 7 forks source link

Composite Primary Keys in Seed #5

Closed amirrajan closed 12 years ago

amirrajan commented 12 years ago

Email from Sasha Cikusa:

Just trying it out and noticed the in the following code (made up test table), SalesPersonRegion is not created with a composite PK

        string tbl = seed.CreateTable("Region", new dynamic[]
        {
            new { RegionId = "int", Identity = true, PrimaryKey = true },
            new { Code = "varchar(2)"},
            new { Name = "varchar(12)"}
        });
        tbl.ExecuteNonQuery(cp);

        tbl = seed.CreateTable("SalesPerson", new dynamic[]
        {
            new { SalesPersonId = "int", Identity = true, PrimaryKey = true },
            new { RegionId = "int", ForeignKey = "Region(RegionId)" },
            new { Name = "varchar(12)"}
        });
        tbl.ExecuteNonQuery(cp);

        tbl = seed.CreateTable("SalesPersonRegion", new dynamic[]
        {
            new { SalesPersonId = "int", PrimaryKey = true, ForeignKey = "SalesPerson(SalesPersonId)" },
            new { RegionId = "int", PrimaryKey = true, ForeignKey = "Region(RegionId)" }
        });
        tbl.ExecuteNonQuery(cp);

It's not uncommon so I wanted to let you know.

amirrajan commented 12 years ago

Fixed here: https://github.com/amirrajan/Oak/blob/master/Oak.Tests/describe_Seed/when_creating_table.cs#L279

Will push packages this weekend.