AL icon indicating copy to clipboard operation
AL copied to clipboard

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

Open tinestaric opened this issue 10 months ago • 0 comments

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:

  • AL Language: 13.0.971907
  • Visual Studio Code: 1.88.0
  • Business Central: 24.0.16410.17628

Internal work item: AB#524620

tinestaric avatar Apr 10 '24 08:04 tinestaric