Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AA0232 The FlowField XXX of "TableName" should be added to the SIFT key. #6140

Closed
salgiza opened this issue Sep 14, 2020 · 35 comments
Closed
Labels
bug Product bug CodeCop This is a specific static-code-analysis group (AA) in-progress static-code-analysis

Comments

@salgiza
Copy link

salgiza commented Sep 14, 2020

Describe the bug
The rule does not seem to be working correctly.

To Reproduce
We haven't been able to reproduce it outside our app (a test app using the same VSCode extension and BC server, with identical code as the one below does not raise the warning). There is something else that I must be missing, but I'm posting it here to see if we can find what.

This is, after a few simplifications, the code I've left in one table field (the original CalcFormula was much more complex):

    field(7142200; "IDPWHS Qty. Buffer"; Decimal)
    {
        CalcFormula = Sum("IDPWHS Read Buffer".Quantity where("Doc No." = field("Document No.")));
        Caption = 'Qty. Read';
        Editable = false;
        FieldClass = FlowField;
        DecimalPlaces = 0 : 5;
    }

It raises this warning: The FlowField Quantity of "IDPWHS Read Buffer" should be added to the SIFT key.

This is the key I've created for that CalcFormula, in the "IDPWHS Read Buffer" table:

    key(Key7; "Doc No.")
    {
        SumIndexFields = Quantity;
    }

Just for reference, this are the "Doc No." and "Quantity" fields:

    field(2; "Doc No."; Code[20])
    {
        Caption = 'Document No.';
        DataClassification = CustomerContent;
    }
    field(6; Quantity; Decimal)
    {
        Caption = 'Quantity';
        DataClassification = CustomerContent;
        DecimalPlaces = 0 : 5;
    }

Expected behavior
There is a SIFT index for the required key and the Quantity field, so no warnings should be raised.

5. Versions:

  • AL Language: 6.0.324421
  • Business Central: 16.
@qutreson qutreson added bug Product bug CodeCop This is a specific static-code-analysis group (AA) static-code-analysis labels Sep 14, 2020
@MattTraxinger
Copy link

I can verify that I have the same issue with the rule.

@dzzzb
Copy link

dzzzb commented Oct 6, 2020

Confirmed, the warning still fires when it has been fixed very specifically: see warning here:

image

but see the key I added just for that purpose here:

image

@dzzzb
Copy link

dzzzb commented Oct 6, 2020

It seems this is also another warning that fires for keys that exist in the base application but to which we cannot add SumIndexFields, which it should not do until we can add them... no point telling us 'you should do X' when you don't let us ;-)

@larswestman
Copy link

Same here. Take a look at this example. I get a warning on field 84 but not 85 even though they are delcared in the same way and use the same underlying table and key.

image
image

@TKapitan
Copy link

TKapitan commented Oct 8, 2020

I have a bit different problem.
The rule does not respect field type, so if we use max on a date field (to find the last date) the warning is useless (SIFT index is for the numeric fields only)...

image

@waldo1001
Copy link
Contributor

Confirmed.. this doesn't make sense either..
image

@mplze
Copy link

mplze commented Nov 13, 2020

Same here, I have added an extension field for Vendor Table and Get sum to form my customize table, I have set SumIndexFields but still appear this misleading information

image

image

image

@mjmatthiesen
Copy link

I can also confirm that this is still creating false errors.

@nareshwar
Copy link
Contributor

Happened to me on a Boolean field!

Screenshot 2021-01-20 at 15 36 48 (2)

@yrest
Copy link
Contributor

yrest commented Jun 15, 2021

Slightly different twist (I think):

tableextension 50000 "My Purch. Inv. Line" extends "Purch. Inv. Line"
{
fields
{
field(50000; "My Application Entry No."; Integer)
{
}
}
keys
{
key(AE1; "My Application Entry No.")
{
SumIndexFields = Quantity;
}
}
}

Above code leads to an error: "The property 'SumIndexFields' can only be set if the specified fields are from the same table.",

Fair enough.

But in another table linking to field in this table extension I get the AA0232 warning, that Quantity must be included in SIFT.

@Koubek
Copy link

Koubek commented Jun 16, 2021

Hello @PaulIvan, is there any progress on this and generally any ETA?

@GreatScott000
Copy link

Any progress?

@MikeGlue
Copy link
Contributor

Anything happening with this? This warning is very useful when it acts correctly, but with all the false warnings and the fact it isn't even recognizing the things I'm fixing I am afraid I have to disable this rule, which is a huge shame.

@GreatScott000
Copy link

Still hoping for an update on the status of this.

@atlanta11950
Copy link

The false warnings are still there. Waiting for a solution..

@dzzzb
Copy link

dzzzb commented Oct 12, 2021

I want an ETA as much as anyone else, but each of our comments like this just sends another useless email to 18 people... Let's just upvote the original post and the replies that say what we want, instead of repeating things over and over again.

@aptMattKoe
Copy link

I know Repos where Issues that no longer get comments are removed because of "not relevant" or "looks like resolved".
So: Hi to the other 19 People who not ignore warnings, I had the same wrong warning....

@PaulIvan PaulIvan removed their assignment Dec 6, 2021
@ghost
Copy link

ghost commented Feb 2, 2022

I have this problem as well.

@BaltzerLogicpartner
Copy link

Also having this problem

@PrebenRasmussen
Copy link

Still seeing this problem!
(AL Language v9.0.586671)

@runesig
Copy link

runesig commented Apr 25, 2022

Me too on v9.0.611415. But it does not always pop up. Can't figure out why it is like this on some fields, but on others that looks exactly the same it does not show up.

@tscottjendev
Copy link

Status update please!

@navdotnetreqs
Copy link

Yeah.. this is still broken over two years after it was reported the first time..

@mazhelez
Copy link
Collaborator

Thanks for reporting this issue. Sorry we haven’t completed it yet, but we’ve had to prioritize elsewhere. We’re planning to give the CodeCop engine and its rules an overhaul in a future major release. Thanks for your patience.

@cr998
Copy link

cr998 commented Nov 17, 2022

Status update please!

@ernestasjuska
Copy link

ernestasjuska commented Jan 13, 2023

Hi, here is some code for reproducing this issue.

.vscode/settings.json:

{
    "al.enableCodeAnalysis": true,
    "al.codeAnalyzers": [
        "${CodeCop}"
    ]
}

app.json

{
  "id": "5bf931d1-ad10-4e81-a8d9-7860a57a688b",
  "name": "ALProject67",
  "publisher": "Default publisher",
  "version": "1.0.0.0",
  "idRanges": [
    {
      "from": 50100,
      "to": 50149
    }
  ],
  "runtime": "10.0"
}

Example.al (I added both cases - without and with table extension; compiler will complain for table extension case, but it doesn't matter)

#region A
table 50100 "XYZ Source A"
{
    fields
    {
        field(1; "Entry No."; Integer) { }
        field(2; "Some Field"; Integer) { }
        field(3; "Some Amount"; Decimal) { }
    }

    keys
    {
        key(PK; "Entry No.")
        {
            Clustered = true;
        }
        key(K2; "Some Field")
        {
            SumIndexFields = "Some Amount";
        }
    }
}

table 50101 "XYZ Target A"
{
    fields
    {
        field(1; "No."; Code[20]) { }
    }
}

tableextension 50101 "XYZ Target A Ext." extends "XYZ Target A"
{
    fields
    {
        field(50100; "Value"; Decimal)
        {
            FieldClass = FlowField;
            CalcFormula = sum("XYZ Source A"."Some Amount" where("Some Field" = const(123)));
            Editable = false;
        }
    }
}
#endregion A

#region B
table 50102 "XYZ Source B"
{
    fields
    {
        field(1; "Entry No."; Integer) { }
        field(2; "Some Field"; Integer) { }
        field(3; "Some Amount"; Decimal) { }
    }

    keys
    {
        key(PK; "Entry No.")
        {
            Clustered = true;
        }
        key(K2; "Some Field")
        {
            SumIndexFields = "Some Amount";
        }
    }
}

table 50103 "XYZ Target B"
{
    fields
    {
        field(1; "No."; Code[20]) { }
        field(2; "Value"; Decimal)
        {
            FieldClass = FlowField;
            CalcFormula = sum("XYZ Source B"."Some Amount" where("Some Field" = const(123)));
            Editable = false;
        }
    }
}
#endregion B

#region C
table 50104 "XYZ Source C"
{
    fields
    {
        field(1; "Entry No."; Integer) { }
        field(2; "Some Field"; Integer) { }
        field(3; "Some Amount"; Decimal) { }
    }

    keys
    {
        key(PK; "Entry No.")
        {
            Clustered = true;
        }
        key(K2; "Some Field")
        {
            SumIndexFields = "Some Amount";
        }
    }
}

tableextension 50100 "XYZ Source C Ext." extends "XYZ Source C"
{
    fields
    {
        field(50100; "Value"; Decimal)
        {
            FieldClass = FlowField;
            CalcFormula = sum("XYZ Source C"."Some Amount" where("Some Field" = const(123)));
            Editable = false;
        }
    }
}
#endregion C

#region D
table 50105 "XYZ Source D"
{
    fields
    {
        field(1; "Entry No."; Integer) { }
        field(2; "Some Field"; Integer) { }
        field(3; "Some Amount"; Decimal) { }
        field(50100; "Value"; Decimal)
        {
            FieldClass = FlowField;
            CalcFormula = sum("XYZ Source D"."Some Amount" where("Some Field" = const(123)));
            Editable = false;
        }
    }

    keys
    {
        key(PK; "Entry No.")
        {
            Clustered = true;
        }
        key(K2; "Some Field")
        {
            SumIndexFields = "Some Amount";
        }
    }
}
#endregion D

The compiler will show these warnings:
image

So the problems are:

  1. The problem detection algorithm does not work sometimes - it should find key with fields used in where condition (in my example "Some Field") and if such key exists it should check if SumIndexFields property includes the source field (in my example "Some Amount").
  2. "Some Amount" is not a flowfield. It is the field which is used to calculate flowfield value.
  3. The message does not include flowfield filter field names - so you usually need to go back and forth between files.

Thanks.

EDIT 1: Added two more cases to example code (C and D). Those also show the same information message.

@TKapitan
Copy link

I think it's not necessary to add additional information. Microsoft does not fix any of these CodeCop warnings soon as it is not their priority.

@salgiza
Copy link
Author

salgiza commented Jan 13, 2023

@mazhelez Now that there is an example to reproduce it, and knowing that this bug still applies, could you consider reopening the ticket? Even if you don't plan to fix it now, at least to make it clear that it still is a problem.

@jonwlong
Copy link

Still not fixed.

@MichelDant21
Copy link

Still not solution.

@cr998
Copy link

cr998 commented Jan 25, 2024

Does anyone knows something about that?
Still not fixed at 2024?

@NKarolak
Copy link

The status of this issue is "Closed", which means that Microsoft won't ever look again into it.
We can only open new issues.

@ashishsharmainecta
Copy link

Still not Fixed. I am getting same warning in case of average based flow field.

@navdotnetreqs
Copy link

Still broken FOUR years after it was reported the first time..

@waldo1001
Copy link
Contributor

@ashishsharmainecta , @navdotnetreqs ,
these mesages will not get read. Issue is closed. MS answered: not a prio - may be in some next major release.. .

Best is to create a new issue if you would like to raise new attention to it.. .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Product bug CodeCop This is a specific static-code-analysis group (AA) in-progress static-code-analysis
Projects
None yet
Development

No branches or pull requests