microsoft / AL

Home of the Dynamics 365 Business Central AL Language extension for Visual Studio Code. Used to track issues regarding the latest version of the AL compiler and developer tools available in the Visual Studio Code Marketplace or as part of the AL Developer Preview builds for Dynamics 365 Business Central.
MIT License
719 stars 242 forks source link

Same-app Table Extensions allow adding keys with the same name that break a dependant extension publishing #7710

Open tinestaric opened 2 months ago

tinestaric commented 2 months ago

1. Describe the bug This is a weird edge case I'd say. You cannot define multiple keys on the core Table with the same name. You can however define additional keys on the Table Extensions that have the same name as the key in the core Table.

Everything compiles and deploys, but when you then create a separate app that also extends the core Table and adds a key that uses a field from the core Table, the publish breaks with an error that multiple keys with the same name exist on the table.

2. To Reproduce

  1. Create App A with these objects and publish it.
table 50100 MyCoreTable
{
    DataClassification = CustomerContent;

    fields
    {
        field(1; EntryNo; Integer) { }
        field(2; Name; Text[50]) { }
    }

    keys
    {
        key(PK; EntryNo)
        {
            Clustered = true;
        }
    }
}

tableextension 50100 MyCoreExtension1 extends MyCoreTable
{
    fields
    {
        field(50100; MyInt; Integer) { }
    }

    keys
    {
        key(PK; MyInt) { }
    }
}

tableextension 50101 MyCoreExtension2 extends MyCoreTable
{
    fields
    {
        field(50101; MyInt2; Integer) { }
    }

    keys
    {
        key(PK; MyInt2) { }
    }
}
  1. Create App B with these objects and publish it.
tableextension 50200 MyCoreExtension1200 extends MyCoreTable
{
    fields
    {
        field(50200; MyInt200; Integer)
        {
            DataClassification = CustomerContent;
        }
    }

    keys
    {
        key(Key200; Name) { }
    }
}

3. Expected behavior An error should be thrown if you declare a key on the TableExt within a same app with the existing name

4. Actual behavior On publish of the App B, errors are thrown

I'm sorry for Dutch error (I don't speak Dutch so it's just as annoying for me) De sleutelnaam PK wordt meerdere keren in tabel MyCoreTable gebruikt door de extensies met de volgende app-id's: 235a48cd-20df-41ac-ace1-74d561e7d0f8, 235a48cd-20df-41ac-ace1-74d561e7d0f8.

Translation: The key name PK is used multiple times in table MyCoreTable by the extensions with the following app IDs: 235a48cd-20df-41ac-ace1-74d561e7d0f8, 235a48cd-20df-41ac-ace1-74d561e7d0f8.

5. Versions: